图:jl:更改logscale tick的更改形式为正常格式
考虑以下图
using Plots
pyplot()
radix_range_xticks = -4:4
radix_range = LinRange(-4, 4, 100)
xs = 2.0 .^ radix_range_xticks
pf = 50.0
bw = 25.0
roofline(x, bw, pf) = min(bw*x, pf)
ys = roofline.(xs, bw, pf)
p = plot(xs, ys; xscale=:log2, yscale=:log10)
xticks!(p, xs)
会导致图片的图。
X-Ticks和Y-Ticks都格式为指数。添加关键字参数xformatter =:Scientific
无济于事,因为它只是更改radix而不是整个数字。
那么,我如何在科学符号中格式化tick呢?我想完全摆脱base^endegons
符号。
我还尝试将字符串
s的迭代性传递到XTICKS!
,但没有在其上派遣。
我试图看在文档中可能会有所帮助。
在Julia lang话语上进行交叉封闭“>在这里
Consider the following plot
using Plots
pyplot()
radix_range_xticks = -4:4
radix_range = LinRange(-4, 4, 100)
xs = 2.0 .^ radix_range_xticks
pf = 50.0
bw = 25.0
roofline(x, bw, pf) = min(bw*x, pf)
ys = roofline.(xs, bw, pf)
p = plot(xs, ys; xscale=:log2, yscale=:log10)
xticks!(p, xs)
This results in a plot that looks like this.
The x-ticks and y-ticks both are formatted as exponentials. Adding the keyword argument xformatter=:scientific
does not help, as it just changes the radix instead of the whole number.
So, how can I format the ticks in e.g. scientific notation? I would like to get rid of the base^exponent
notation altogether.
I also tried passing an iterable of String
s to xticks!
, but it does not dispatch on it.
I tried to look here in the documentation, but could not anything else that might help.
Crossposted on the Julia lang discourse here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅通过一个峰值的字符串将无法工作,该图还需要有关将这些字符串放在X轴上的信息。以下工作可以完成工作。
将最后一个参数替换为tick所需的任何格式。
Passing only an iterable of strings would not work, the plot also needs information about where to place those strings on the x-axis. The following does the job.
Replace the last argument with whatever formatting is required for the ticks.
您可能需要检查ControlSystems/plotting.jl(getLogticks)。
它似乎有使用科学符号的案例。以下使用壁虱数量来决定使用纯指数还是科学:
You might want to check out ControlSystems/plotting.jl(getLogTicks).
It seems to have a case for using scientific notation. The following uses number of ticks to decide whether to use pure exponent or scientific: