我想根据矢量中的值更改2D散点图的标记样式,最终在两个轴上显示3个尺寸。以下是我想要做的以及我在尝试时得到的错误。
x = rand(1:30,100)
y = rand(20:30,100)
MyMarker = [fill("o",50);fill("x",50)]
scatter(x,y,marker=MyMarker,alpha=0.5)
LoadError: PyError (:PyObject_Call) <type 'exceptions.ValueError'>
ValueError(u"Unrecognized marker style ['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x']",)
File "/home/lara/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 3251, in scatter
edgecolors=edgecolors, data=data, **kwargs)
File "/home/lara/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/__init__.py", line 1812, in inner
return func(ax, *args, **kwargs)
File "/home/lara/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/axes/_axes.py", line 3877, in scatter
marker_obj = mmarkers.MarkerStyle(marker)
File "/home/lara/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/markers.py", line 171, in __init__
self.set_marker(marker)
File "/home/lara/.julia/v0.4/Conda/deps/usr/lib/python2.7/site-packages/matplotlib/markers.py", line 252, in set_marker
' {0}'.format(marker))
while loading In[91], in expression starting on line 1
in getindex at /home/lara/.julia/v0.4/PyCall/src/PyCall.jl:228
in pysequence_query at /home/lara/.julia/v0.4/PyCall/src/conversions.jl:717
[inlined code] from /home/lara/.julia/v0.4/PyCall/src/conversions.jl:733
in pytype_query at /home/lara/.julia/v0.4/PyCall/src/conversions.jl:762
in convert at /home/lara/.julia/v0.4/PyCall/src/conversions.jl:782
in pycall at /home/lara/.julia/v0.4/PyCall/src/PyCall.jl:363
in call at /home/lara/.julia/v0.4/PyCall/src/PyCall.jl:372
in close_queued_figs at /home/lara/.julia/v0.4/PyPlot/src/PyPlot.jl:401
我尝试了以下内容,这两者都不是我想要做的,但它们足够接近,但都不起作用。
using Plots
pyplot(size=(400,200), legend=false) # set backend and set some session defaults
scatter(rand(30),m = ColorGradient([:red,:green,:blue]),zcolor = repmat([0,0.5,1],10))
using Plots
pyplot(size=(400,200), legend=false) # set backend and set some session defaults
scatter(rand(30),
m = ColorGradient([:red,:green,:blue]), # colors are defined by a gradient
zcolor = repmat([0,0.5,1],10) # sample from the gradient, cycling through: 0, 0.5, 1
)
有谁能告诉我如何让标记接受矢量?
更新 我有一个解决方法,但我不想这样做:将数据分成不同的集合,然后将它们绘制在相同的轴上:
PyPlot.plot(spacerdataActualSpacer[:Length],spacerdataActualSpacer[:Curvature],marker="x",".")
PyPlot.plot(spacerdataNoActualSpacer[:Length],spacerdataNoActualSpacer[:Curvature],marker="o",".")
答案 0 :(得分:1)
你可以尝试一些不同的东西(我在Plots dev上,所以我不能确定什么对你有用):
scatter(rand(30), group = repmat(1:3,10), marker=:auto)
scatter(rand(30), group = repmat(1:3,10), shape=[:+ :o :utri])
scatter(rand(30), group = repmat(1:3,10), shape=[:+ :o :utri], layout=(3,1))
如果您想要的话,请告诉我。说实话,我并不完全确定我知道你理想的viz会是什么样子。