How to set series colors from parameter?

I’m plotting different series (from the columns in a 2D Array) and I would like to set the color of each series according to a parameter. In the example, I would like to set the color of the line at the bottom to the black and the line at the top to be yellow.

plot(collect(1:10), [i*j for i in 1:10, j in 1:10], zcolor = collect(1:10), 
    m = :o, ms = 10,
    label = transpose(collect(1:10)))

example

I tried using the zcolor keyword but I think I;m not using it correctly…

Does anyone know how I can obtain this behavior? Do I need to use PlotRecipesor something similar?
Thanks for your help

Try

plot(1:10, (1:10)*(1:10)', marker_z = (1:10)',
           line_z = (1:10)', m = :o, ms = 10,
           label = (1:10)', legend = :topleft)

What I’ve done (apart from removing some unnecessary collects) is to transpose the arguments to line_z (for the lines) and marker_z for the markers, so that they operate across, rather than within, series.

2 Likes

Thank you very much @mkborregaard, I didn’t know about the line_z and marker_z attributes, it’s exactly what I nedded. :slightly_smiling_face: