I am trying to make a surface plot without the axis and grid lines. I found that I can turn off the grid with grid = false
but I can't find a way to remove the axis lines.
surface(x2d, y2d, z2d, fill_z = color_mat, fc = :haline, grid=false)
Run Code Online (Sandbox Code Playgroud)
Thanks!
使用 Plots.jl 我可以根据两个向量绘制散点图,并由另一个向量设置颜色,如下所示:
using Plots
scatter([1,3,5,7], [2,4,6,10], marker_z = [1,1,2,3])
Run Code Online (Sandbox Code Playgroud)
该系列既有图例,也有颜色条。
如果我设置legend = false
两者都被删除:
scatter([1,3,5,7], [2,4,6,10], marker_z = [1,1,2,3], legend = false)
Run Code Online (Sandbox Code Playgroud)
我想删除该系列的图例(框中的“y1”),并保留颜色条。有谁知道这是怎么做到的吗?谢谢。
我想使用 Plots.jl 为一组子图添加全局标题。
理想情况下,我会这样做:
using Plots
pyplot()
plot(rand(10,2), plot_title="Main title", title=["A" "B"], layout=2)
Run Code Online (Sandbox Code Playgroud)
但是,根据Plots.jl 文档,该plot_title
属性尚未实现:
整个情节的标题(不是子情节)(注意:当前未实施)
同时,有什么办法可以解决吗?
我目前正在使用pyplot
后端,但我并没有特别依赖它。
根据文档,Julia Plots 中的 annotation 属性似乎只采用 x,y 坐标和标签的元组。有没有办法在 3D 绘图上做到这一点?例如:
tvec=0:0.1:4*pi
plot(sin, tvec)
annotate!(pi/2,1.0,"max")
annotate!(3*pi/2,-1.0,"min")
Run Code Online (Sandbox Code Playgroud)
tvec=0:0.1:4*pi
plot(tvec, sin(tvec), cos(tvec))
Run Code Online (Sandbox Code Playgroud)
代码
using Plots
pyplot(markershape = :auto)
for i in 1:4
plot!(rand(10), label = "Series " * string(i))
end
savefig("Plot.png")
Run Code Online (Sandbox Code Playgroud)
产生以下情节:
标记不会出现在图例中,只会显示数据系列的线条颜色.这使得将线条与图例中的标签进行匹配变得非常困难,特别是对于那些色盲或读取黑白打印输出的人.有没有办法在图例中显示绘图标记和线条颜色?
Plots.jl
我正在调试一个脚本(与后端一起使用GKS QtTerm
)。所以我多次运行该脚本。当我从终端运行它时,bash> julia pointPlacement.jl
需要很长时间才能初始化 Julia 和 Plots.jl(与 python 相比,这是一大不便)。因此,我宁愿让 Julia 保持打开状态并从内部运行脚本,例如julia> include( "pointPlacement.jl" )
grid = [ [ix*0.01 iy*0.01] for ix=1:100, iy=1:100 ]
grid = vcat(ps...)
centers = hexGrid( 2, 0.2 )
using Plots
display(scatter!( grid[:,1], grid[:,2], markersize = 1, markerstrokewidth = 0, aspect_ratio=:equal ))
display(scatter!( centers[:,1], centers[:,2], markersize = 2, markerstrokewidth = 0, aspect_ratio=:equal ))
Run Code Online (Sandbox Code Playgroud)
问题是地块不断累积。这是运行 9 次之后的结果。应该只有 2 个数据集,而不是 18 个:
我想关闭(杀死、摧毁)它们
如果我!
像这样删除,它会有所帮助
display(scatter( grid[:,1], grid[:,2], markersize = 1, markerstrokewidth …
Run Code Online (Sandbox Code Playgroud) 有谁知道如何用朱莉娅的Pyplot绘制3D表面,例如表面渐变的标准作为面部颜色?
与Python的此主题类似:使用曲面渐变的颜色matplotlib plot_surface命令
Plots
虽然简单而且功能强大,但有时候我想更多地控制情节中的各个元素以微调它的外观.
是否可以直接更新后端的绘图对象?
例如,对于默认pyplot
后端,我试过了
using Plots
p = plot(sin)
p.o[:axes][1][:xaxis][:set_ticks_position]("top")
Run Code Online (Sandbox Code Playgroud)
但情节不会改变.p.o[:show]()
之后的电话也无济于事.
换句话说:有没有办法将PyPlot
界面用于最初创建的图Plots
?
编辑:
PyPlot
保存图形时,对象的更改将变为可见(也在gui中):
using Plots
using PyPlot
p = Plots.plot(sin, top_margin=1cm)
gui() # not needed when using the REPL
gca()[:xaxis][:set_ticks_position]("top")
PyPlot.savefig("test.png")
Run Code Online (Sandbox Code Playgroud)
在这里,我用过p.o[:axes][1] == gca()
.必须设置top_margin=1cm
因为绘图区域没有自动调整(对于我的实际微调,这没关系).
只要仅使用PyPlot
接口,这也适用于后续更新.例如,在以下命令之后,除了顶部的标签之外,绘图还将具有红色右边框:
gca()[:spines]["right"][:set_color]("red")
PyPlot.savefig("test.png")
Run Code Online (Sandbox Code Playgroud)
但是,当使用Plots
类似命令时plot!(xlabel="foo")
,所有先前所做的更改都将PyPlot
被覆盖(这并不令人惊讶).
剩下的问题是如何以交互方式更新gui而无需PyPlot.savefig
明确调用.
在 Julia 中,有没有一种方法可以像df.plot()
Python 的 Pandas 一样绘制数据框?
更具体地说,我正在使用Plots
,plotlyjs()
和DataFrames
包。
以下是 Julia Discourse 的最小工作代码:
using LightGraphs
using GraphPlot
using Colors
g = graphfamous("karate")
membership = [1,1,1,1,1,1,1,1,2,1,1,1,1,1,2,2,1,1,2,1,2,1,2,1,1,1,1,2,1,1,2,1,1,1]
nodelabels = 1:34
nodecolor = [colorant"lightgrey", colorant"orange"]
nodefillc = nodecolor[membership]
colors = [colorant"lightgray" for i in 1:78]
colors[42] = colorant"orange"
gplot(g, nodefillc=nodefillc, layout=circular_layout, edgestrokec=colors, nodelabel=nodelabels)
Run Code Online (Sandbox Code Playgroud)
我成功获得了从 1 到 34 的节点标签,但是,我需要为某些特定节点显示另一种类型的标签。例如,某些节点的权重。也就是说,例如,我需要节点 19 的权重为 100,节点 1 的权重为 0.001。
有没有办法显示这样的数据?我可以在 GraphPlot 中找到相关关键字(只有 nodelabel 只接受向量),但我找不到另一个可以用于绘制图形的 Julia 包。
编辑感谢@Dan Getz,在发布到 SE 之前,我有与他建议相同的想法:尝试用格式的字符串标记节点"$i\n $weight"
但是,结果非常令人不满意,正如您在我的一张照片中看到的那样实际图表。橙色的节点 12,与其权重 177.0 分开,\n
读起来不太好!
编辑感谢 @Przemyslaw Szufel 也许我的问题可以通过Compose
(我实际上已经使用过)来解决,这是GraphPlot
. …