From: Petra on
Hi all,
how can I plot one single line plot with different colors in the same line?
For example, I want to plot only the negative values in red and the postitve values in black.
To plot the data points in different colors is easy, but the line between (through zero) is the problem
Thanks
From: Petra on
just the example:
x=[1 3 4.3 6 8 10];
y=[3 -2 -1 3 5 -6];
plot(x,y)
the negative values should be red
From: sscnekro on
Hi Petra,

no idea how to do it, but I just try to imagine the chart as you suggest. Does sb else require it from you or do you have an option how to design your chart? If it is up to you, 'd you not prefer to shade the 'intervals' that are negative? In economics, such plots are often seen with booms and recessions, where the recessions (consecutive decline in the variable) are shaded. That sort of a chart may tell your story better than forcing one and the same line to have two or more colours. If you type in your browser NBER recessions to look for images, you will hit on some examples.