朱莉娅Julia中的标题与PGFPlots左对齐

问题描述

我在Julia中使用PGFPlots.jl包来生成图形。我想使图形标题保持对齐(而不是认居中)。这是我用朱莉娅(Julia)语言写的MWE:

using PGFPlots
p = Plots.Linear3(rand(10),rand(10),mark = "none")
Axis(p,title = "(a)")

获取的图形的标题认情况下居中对齐。如何修改上面的Julia代码以使标题“(a)”保持对齐?

谢谢。

解决方法

PGFPlots.Axis提供了关键字参数style,您可以在其中粘贴pgfplots的选项。

在这种情况下,您可以将标题固定在边界框的左上方(即西北)。

using PGFPlots
p = Plots.Linear3(rand(10),rand(10),mark = "none")
a = Axis(p,title="(a)",style="title style={at={(current bounding box.north west)},anchor=west}")

背景:一般为PGFPlots.jl

要使用PGFPlots.jl实现更多目标,我建议检查软件包生成的LaTeX代码。然后,您可以查阅pgfplots已有的许多资源。

println(PGFPlots.tikzCode(a))

输出的第一行将是:

\begin{axis}[
  title = {(a)},title style={at={(current bounding box.north west)},anchor=west}
]

...

如您所见,我们提供的style参数只是作为axis环境的选项而粘贴的。如果您发现如何在pgfplots后端中更改绘图,则可以立即通过style参数应用此知识。

the documentation of PGFPlots.jl

中给出了许多大图的示例