2

I use PGFPlots.jl package in Julia to produce figures. I would like to have the title of figure being left aligned [instead of being centered by default]. Here is my MWE in Julia language:

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

The title of the obtained figure is aligned center by default. How could I modify the above Julia code to have the title "(a)" being left aligned?

Thank you in advance.

4

1 回答 1

2

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

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

using PGFPlots
p = Plots.Linear3(rand(10), 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参数应用这些知识。

PGFPlots.jl 的文档中提供了许多出色绘图的示例

于 2020-11-17T15:26:38.180 回答