Way to get default color order in Plots.jl?

question

#1

If you’re using pgfplots() through Plots.jl the colors are not the obvious ones you think they would be (i.e. :blue, :red, :green)?

Is there a way to get the default color order within the Plots.jl framework?


By picture, notice the two are different. I want to be able to pipe in the blue and red colors from the left one.

// edit: does it come from Colors.jl?


also can you do a matlab style hold on to keep the color from rotating so you can make multiple plot! calls?


#2

Closing this. For future readers, the answer is:

get_color_palette(:auto, plot_color(:white), 17)

As in,

cur_colors = get_color_palette(:auto, plot_color(:white), 17)
pp = linspace(0,1)

plot()
for (cur_index, cur_color) in enumerate(cur_colors[1:7])
    plot!(pp, 0+pp+cur_index-7)
end
for (cur_index, cur_color) in enumerate(cur_colors[1:7])
    plot!(pp, 1-pp+cur_index-7, color=cur_color)
end
plot!()


#3

You can simply pass an integer i as the argument to color to select the ith default color. So this is equivalent to your code:

pp = [0,1]
plot()
for i = 1:7
    plot!(pp, 0+pp+i-7)
end
for i = 1:7
    plot!(pp, 1-pp+i-7, color=i)
end
plot!()

I think this is still undocumented.


#4

Different PlotThemes have different color palettes. You get the the color palette of a theme with palette(thm::Symbol), so for the default theme this would be palette(:default).