latex - Julia 策划问题 : label overlap and LaTeXStings expansion

标签 latex julia plotly plots.jl juno-ide

我在下面的示例图中遇到了两个相互排斥的问题。

  1. y 轴标签和 y 刻度标签彼此重叠。我有 也没能找到转移的方法。我想 要扩展的图的大小以适应必要的间距。
  2. 我希望 y 轴标签是带有下标 theta 的 sigma。看起来 Unicode 不允许下标 theta。我希望通过使用 LaTeXStrings 来绕过这个限制。但是,我无法将 LatexString 扩展为图上的适当形式。请注意,无论是否使用 LatexString 作为 ylabel,问题 #1 都会发生,并且 LatexString 扩展也不适用于其他字符串值。

下面提供了示例图、代码和数据以供重现。我在 Windows 上使用带有 Plotly 后端的 Juno 编辑器。

Sample plot showing y-axis issues

using Plots, DelimitedFiles, LaTeXStrings
plotly(linewidth=3,titlefont=18,legendfont=16,guidefont=18,tickfont=14,formatter=:plain)
data=readdlm("hoopstress.txt",skipstart=1)
r=data[:,2]
σθ=data[:,end-1:end]
plot(r,σθ,label=["Simplified Vessel" "Full Vessel"],xlabel="r",ylabel=L"\sigma_\theta")
    Length  Simple  Full
1   0.  53280   56859
2   9.4e-2  52158   55405
3   0.1875  51036   53951
4   0.28125 49915   52498
5   0.375   48793   51044
6   0.46875 47671   49590
7   0.5625  46550   48136
8   0.65625 45428   46682
9   0.75    44307   45228
10  0.84375 43185   43774
11  0.9375  42063   42320
12  1.0312  40942   40866
13  1.125   39883   39411
14  1.2187  39256   38780
15  1.3125  38629   38150
16  1.4062  38002   37519
17  1.5 37375   36888
18  1.5938  36748   36257
19  1.6875  36121   35627
20  1.7813  35494   34996
21  1.875   34867   34365
22  1.9688  34239   33735
23  2.0625  33612   33104
24  2.1562  32985   32473
25  2.25    32389   31842
26  2.3437  31998   31441
27  2.4375  31607   31039
28  2.5312  31216   30637
29  2.625   30825   30235
30  2.7187  30434   29833
31  2.8125  30043   29431
32  2.9062  29652   29029
33  3.  29261   28628
34  3.0938  28870   28226
35  3.1875  28479   27824
36  3.2813  28088   27422
37  3.375   27714   27020
38  3.4688  27452   26693
39  3.5625  27190   26367
40  3.6563  26927   26040
41  3.75    26665   25714
42  3.8438  26403   25387
43  3.9375  26141   25061
44  4.0313  25879   24734
45  4.125   25617   24408
46  4.2187  25354   24081
47  4.3125  25092   23755
48  4.4062  24830   23428
49  4.5 24568   23102

最佳答案

我提交了一份 PR解决问题,刚刚合并到master :-)

所以以后你就可以做到

plotly(linewidth=3,titlefont=18,legendfont=16,guidefont=18,tickfont=14,formatter=:plain)
r = 1:10
σθ = [100000 ./ (1:10) .+ 10000, 100000 ./ (1:10) .- 1000 .+ 10000]
plot(r , σθ, label=["Simplified Vessel" "Full Vessel"],
    xlabel = "r",
    ylabel = L"\sigma_\theta\\\color{white}.",
    yformatter = :plain,
    include_mathjax = "cdn",
    extra_kwargs = :plot)

如果您已连接到互联网。

对于本地使用,如果安装了 Conda 和 IJulia,并且按照我之前的回答中的描述复制了 TeX 字体,您可以执行以下操作。

import Conda.ROOTENV
function local_mathjax()
    joinpath(ROOTENV, "Lib", "site-packages", "notebook", "static", "components", "MathJax",
            "MathJax.js?config=TeX-AMS-MML_HTMLorMML-full")
end

plotly(linewidth=3,titlefont=18,legendfont=16,guidefont=18,tickfont=14,formatter=:plain)
r = 1:10
σθ = [100000 ./ (1:10) .+ 10000, 100000 ./ (1:10) .- 1000 .+ 10000]
plot(r , σθ, label=["Simplified Vessel" "Full Vessel"],
    xlabel = "r",
    ylabel = L"\sigma_\theta\\\color{white}.",
    yformatter = :plain,
    include_mathjax = local_mathjax(),
    extra_kwargs = :plot)

y 轴数字的格式现在通过 yformatter = :plain 实现,y 标题中的空间通过添加带有白色格式点的线来实现。

当然,您也可以将 mathjax 副本放置在系统的某个位置,并将链接放在 includ_mathjax 参数中。

可以在 PR 中找到有关用法的更多详细信息。 编码愉快!

关于latex - Julia 策划问题 : label overlap and LaTeXStings expansion,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61731322/

相关文章:

scope - 虽然没有全局

for-loop - julia 模块中的变量范围如何工作?

julia - Julia 多重调度入门

python - 禁用 Python 中的 Plotly 以任何形式与网络通信

latex - latex 宽长 table

latex - 如何在 LaTex 中第一个部分出现的位置开始页码?

latex - 如何将包含空格的选项传递给 LaTeX/XeLaTeX 中的包

latex - 如何在 LyX 中显示更多文本?让页面更宽?

callback - 使用 plotly express 并在一页上有多个图形时,随机出现导入错误

r - 如何在 R 中为悬停文本配置千位分隔符?