I often make 2-d plots showing a comparison of cases with a parameter 'On" of 'Off'. So I'll have several curves for the first case and then another set, using dashed lines, for the second case.
%The code would be pre 2014b
plot(x,y_on)
hold on
plot(x,y_off,'--')
How can I get the same result in 2014b?

 採用された回答

Jesse
Jesse 2014 年 12 月 8 日
編集済み: Jesse 2014 年 12 月 8 日

1 投票

I use
set(gca, 'ColorOrderIndex', 1)
between calls to reset the color order, and give you the same behavior as pre-2014b

2 件のコメント

Julius Kusuma
Julius Kusuma 2015 年 3 月 4 日
The caveat is that this has to be called BEFORE "hold on". A bit annoying, MathWorks should change this.
Mike Garrity
Mike Garrity 2015 年 7 月 1 日
I'm not clear on what you're referring to. I get exactly the same result if I do this:
rng(0)
figure
plot(randn(1,100))
set(gca,'ColorOrderIndex',1)
hold on
plot(randn(1,100))
or this:
rng(0)
figure
plot(randn(1,100))
hold on
set(gca,'ColorOrderIndex',1)
plot(randn(1,100))

サインインしてコメントする。

その他の回答 (2 件)

the cyclist
the cyclist 2014 年 12 月 7 日

0 投票

Did the behavior of
hold on
change in 2014b? I didn't think so. I continue to use it normally.
What specific problem are you seeing? Can you plot a small, fully executable piece of code that results in something unexpected?

3 件のコメント

Sean de Wolski
Sean de Wolski 2014 年 12 月 8 日
It did change, hold on now continues using the next color on the axes' colororder.
Mike Garrity
Mike Garrity 2015 年 7 月 1 日
The pre-14b behavior of "hold all" finally got promoted to "hold on".

サインインしてコメントする。

M J Schwartz
M J Schwartz 2015 年 7 月 1 日

0 投票

You can edit hold.m (it is just an ascii mfile)
Add, 'ColorOrderIndex',1 in two places
...
elseif(strcmp(opt_hold_state, 'on'))
set(fig,'NextPlot','add');
set(ax,'NextPlot','add', 'ColorOrderIndex',1);
...
elseif(strcmp(opt_hold_state, 'on'))
set(fig,'NextPlot','add');
set(ax,'NextPlot','add', 'ColorOrderIndex',1);
save hold.m to a directory that is before all of matlab's stuff in your path. save as: ~/matlab/mymfiles/hold.m add to your startup.m path('~/matlab/mymfiles'], path)
Arrogant "improvement" of default behavior (in this case, matlab removed the default behavior of hold.m from even being an option!?) is a real PIA for someone with 20+ years of code. Don't get me started on perula, which lets us all see what it is like to be colorblind.

2 件のコメント

Steven Lord
Steven Lord 2015 年 7 月 1 日
With respect to the parula colormap, Steve Eddins did a four part blog series discussing why we made the colormap change. The feedback in the comments was generally positive. But there were some people who indicated they preferred or needed the jet colormap (the previous default) to which I responded:
"Note that the JET colormap is still included in MATLAB. You can change your figure or axes colormap to use JET using the COLORMAP function; you can even set it as the default figure or axes Colormap if you like.
You can put the command to change the default colormap in your startup.m file in your startup directory if you want to always use jet.
David
David 2015 年 8 月 6 日
M J,
Agreed, the change in hold is rather foolish. Why not just leave well enough alone?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Color and Styling についてさらに検索

製品

質問済み:

2014 年 12 月 7 日

コメント済み:

2015 年 8 月 6 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by