通过PyCall在Julia设置seaborn

时间:2017-01-16 20:14:56

标签: python matplotlib plot julia seaborn

我使用seaborn来绘制朱莉娅。但是,我无法弄清楚如何解析set_style的certaiin属性,例如python中的行将是

sns.set_style('darkgrid', {'axes.linewidth': 2, 'axes.edgecolor':'black'})

举一个最小的例子:

using PyPlot
using PyCall
@pyimport seaborn as sns


test_plot()
function test_plot()
  clf()
  #- - -
  sns.set_style("ticks",???)
  # - - -
  tmp_plt=figure("plot1",figsize=(4.5, 3.5))
  x=collect(0:0.5:3)
  plot(x,0.4.*x)
  plot(x,x.^0.5)
end

有谁知道如何更换'???'在julia中,它对应于python输入{'axes.linewidth': 2, 'axes.edgecolor':'black'}

非常感谢:)

编辑: 我找到了一个使用rc的解决方法,以供将来参考:

using PyPlot
using PyCall
@pyimport seaborn as sns

close()
test_plot()
function test_plot()
  sns.set_context("notebook", font_scale=1.4)
  sns.set_style("ticks")
  rc("font",family ="Computer Modern Roman")
  rc("lines",linewidth = 2.5)
  rc("axes",linewidth = 2,edgecolor=".55")
  rc("axes",grid=true)
  rc("grid",linestyle="-",color="1.0")
  rc("legend",frameon=true,edgecolor="none",facecolor="0.85")
  rc("axes",facecolor="0.96")
  rc("axes",titlesize="large")
  tmp_plt=figure("plot1",figsize=(8, 6))
  ax=gca()
  x=collect(0:0.5:3)
  plot(x,0.4.*x)
  plot(x,x.^0.5)
  tmp=legend(["Tmp 1", "Tmp 2"],loc=2,bbox_to_anchor=[0.0015,0.997],borderaxespad=0)
  xlabel("basic x",labelpad =5.0)
  ylabel("basic y",labelpad =5.0)
  title("\$ \\sum x^2\$",y=1.08)
  tight_layout()
  savefig("fig2.pdf")
end

1 个答案:

答案 0 :(得分:0)

我不知道seaborn,但朱莉娅相当于Python

{'axes.linewidth': 2, 'axes.edgecolor':'black'}

就是

Dict("axes.linewidth" => 2, "axes.edgecolor" => "black")
相关问题