语法包括在PGFPlots注释节点内声明的变量的值?



在Julia中,我声明了一个变量,比如x = 3.5。现在我想使用PGFPlotsX将该变量包含在绘图的某些注释中。

x = 3.5
using PGFPlotsX
@pgf Axis(
plot(
Table(
),
),
raw"node[anchor = south west] at (.3,.3){$x = <variable name i.e., x >$}"
) 

节点内的$$应该使用什么语法?我想避免在节点内硬编码x的值3.5。

您的问题是,当您使用@raw_str宏定义为:

时,您想在String内插入:
help?> @raw_str
@raw_str -> String
Create a raw string without interpolation and unescaping. (...)

所以你可以做的是不使用raw",但你需要逃离$:

"node[anchor = south west] at (.3,.3){$x = $x >$}"

这将很好地插入x

第二个选项是连接Strings:

string(raw"node[anchor = south west] at (.3,.3){$x = ", x, raw"  = $x >$}")

最新更新