Is it possible to set the "linetype" in gnuplot while using "linecolor variable"?

gnuplot

Solution

This looks like a bug to me. Unfortunately, I don't think too many gnuplot devs hang out on StackOverflow, so we might not ever find out. (I would encourage you to submit a bug report though and keep me updated on any progress that might be made)...

If you're really using `column(-2)` to pick out the colors, the problem becomes a lot easier and you should be able to do that using plot iteration (as long as you know an upper limit on the number of datasets).

NDSET=3 #This will issue a warning if NDSET is too big, but will still work.
plot for [IDX=0:NDSET] 'example.dat' index IDX using 1:2 with lines linetype 5 linecolor IDX+1

The indexing starts from 0 and corresponds to `column(-2)`. Linecolor `0` isn't defined (I don't know why gnuplot uses two different conventions here -- I suppose because in theory the colors corresponding to any particular linestyle are terminal dependent, so it doesn't really matter too much anyway...)

Problem

I have a tab-separated data file containing a number of (double-blank-line-separated) datasets and I want to plot a line for each of them. I want to be able to set the linetype (by this I'm referring to solid/dashed/dotted). I want each line to be a different color. I can plot them all different colors using this: ``` plot 'example.dat' using 1:2:(column(-2)) with lines linecolor variable ``` And I can set the linetype but plot them all the same color using this: ``` plot 'example.dat' using 1:2:(column(-2)) with lines linetype 5 ``` But when I combine them, the linetype is not what I set it to (in this case I just get a solid line). ``` plot 'example.dat' using 1:2:(column(-2)) with lines \ linetype 5 linecolor variable ``` Is there a way to achieve this? I'm using gnuplot 4.6, tried with the x11 and postscript terminals.

Original source