I want to plot a series of lines, with each line being colored according to a certain weight. I stumbled accross this, but the problem is, I am plotting multiple things on one graph, where only one of the plot statements should be color weighted.
I'm using hold on; hold off;
, but I only see the last graph. Thus, the final result is, I only see the color weighted plot statements, but not the other plot statements that should be plotted due to hold on; hold off;
.
Here is my code, where upper*p
is an n x 1 vector representing the intensity of each of the n lines:
cmap = colormap;
con_min = min(upper*p)*25;
con_max = max(upper*p)*25;
ind_upper = ceil((size(cmap,1)-1)*((con_min:con_max)'-con_min+1)/(con_max-con_min));
subplot(2,3,2);
hold on;
title('Gains');
set(gca,'ColorOrder',cmap(ind_upper,:),'NextPlot','replacechildren');
plot(flat','c');
plot(lower','c');
plot(upper');
set(gca, 'xtick',1:labelFreq:num_tickers, 'xticklabel', tickers(1:4:num_tickers));
ylabel('bp change on day');
colorbar;
caxis([con_min con_max]);
hold off;
It seems the "upper" part is plotted correctly according to the color weights, but the "flat" and "lower" graphs do not show. I think it's because the set(gca,...) statement is causing the graphs to reset.