In matlab I can achieve this result using the structure of this minimal working example (in matlab):
figure('color','white'); hold on
xx=0:1;
colors = parula(5);
for i = 1:5
color = colors(i,:);
plot(xx, xx*i, 'color', color);
end
h = colorbar('Ticks',0:0.25:1,'TickLabels',{'1','2','3','4','5'});
h.Label.String = 'line slope';
which produce this:
I would like to do the same in pgfplots but i really don't know hot to do it!
For the curves I surely would load the data from tables, but for the color code and color bar I have no idea.
Anyone can help me?
Thanks
Best Answer
I took a parula scale written by Jake and defined the
colormap
to use it. The curves are plotted with a for-each loop. I set the meta data of the points to the slope variable. The optionmesh
plots the lines with the colour of its meta data.As asked in your comment, here is a solution loading data from files: