【问题标题】:seaborn setting in Julia via PyCall通过 PyCall 在 Julia 中设置 seaborn
【发布时间】:2017-05-31 18:12:54
【问题描述】:

我使用 seaborn 在 Julia 中进行绘图。但是,我不知道如何解析 set_style 的某些属性,例如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

【问题讨论】:

  • 你为什么要涉及seaborn? (以及当您可以将 Plots.jl 与 PyPlot 后端一起使用时,为什么还要使用 PyPlot)
  • @LyndonWhite 或许 OP 刚刚开始接触 Julia,并依赖于熟悉的软件包。 Seaborn 基于 matplotlib 构建,为统计绘图提供了方便而强大的界面。

标签: python matplotlib plot julia seaborn


【解决方案1】:

我不知道 seaborn,但是 Julia 相当于 Python

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

很简单

Dict("axes.linewidth" => 2, "axes.edgecolor" => "black")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多