在朱莉娅0.5你可以写:
using DataFrames, Plots, StatPlots
df = DataFrame(
fruit = ["orange","orange","orange","orange","apple","apple","apple","apple"],
year = [2010,2011,2012,2013,2010,2011,2012,2013],
production = [120,150,170,160,100,130,165,158],
consumption = [70,90,100,95, 80,95,110,120]
)
plotlyjs()
mycolours = [:green :orange]
legend1 = sort(unique(df[:fruit]))
legend2 = legend1'
fruits_plot = plot(df, :year, :production, group=:fruit, linestyle = :solid, linewidth=3, label = ("Production of " * legend2), color=mycolours)
其中legend1
是2-element DataArrays.DataArray{String,1}
而legend2
是1×2 DataArrays.DataArray{String,2}
。
现在,在朱莉娅0.6 legend2 = legend1'
不再工作了。您可以改为使用legend2 = reshape(legend1, (1, :))
,但这会产生一个相当模糊的1×2 Base.ReshapedArray{String,2,DataArrays.DataArray{String,1},Tuple{}}
,然后在plot()
调用中不会被接受。
那么,从2-element DataArrays.DataArray{String,1}
1×2 DataArrays.DataArray{String,2}
生成julia 0.6的任何方式?
答案 0 :(得分:1)
再次,在SO上发帖有助于..; - )
我终于得到了我可以获得预期字符串连接的情节:
fruits_plot = plot(df, :year, :production, group=:fruit, linestyle = :solid, linewidth=3, label= reshape("Production of " * sort(unique(df[:fruit])),(1,:)), color=mycolours)