Plotting two or more fints, plot is splitting up, how to stop?

1 Ansicht (letzte 30 Tage)
Lindsay Jamieson
Lindsay Jamieson am 17 Nov. 2016
Kommentiert: dpb am 18 Nov. 2016
I am plotting some qty N financial time series as follows:
plot([fints1 fints2 ... fintsN])
or some subset thereof. Which works fine most of the time. Except sometimes for some subsets of these fints it plots fints1 on one axis then just puts another axis above it and plots the next fints2 and the remaining fintsx to N on this new axis. I want all the plots on the same axis. I'm baffled. All the date/time (x axis) points match in each fintsx and all the numbers being plotted are type double.
I'll try to illustrate here.
If I run this, which works about 75%:
plot([two_yr five_yr])
legend('2y','5y','Location','Best')
I get this about 25% of the time:
This series of script puts out what I want but is untenable in the larger scheme of things for some reasons:
hold on
plot(two_yr)
plot(five_yr)
legend off
legend('2y','5y','Location','Best')
hold off
This is how it appears, as desired:

Akzeptierte Antwort

dpb
dpb am 17 Nov. 2016
Turns out it's documented behavior... "The plot command automatically creates subplots when multiple time series are encountered, and they differ greatly on their decimal scales..."
See <finance/plot>. It doesn't indicate you can pass an axis handle to this overloaded plot function to force it to add to an existing plot.
Not sure just what you would run into just forcing to use the base Matlab plot routine; certainly would have to deal with the object type of casting to double and dealing with the date/time stuff that's automagic in the other.
I don't have Fin TB so can't try it here to know what would be a useful workaround, sorry...I'd suggest this is worth a call to Tech Support at TMW for their suggestion.
Oh...a thought...what happens if you try the first and then execute hold on on that axes and then call plot again with the second series? If that adds to the existing axes, maybe you can devise some logic that you can use to automate it to avoid the hassle.
Only other thing I can think of would entail a lot of munging in trying to take the one subplot data from one and copyobj to the second and then deleting the first subplot and resizing the second and that's just too messy to think about...
  2 Kommentare
Lindsay Jamieson
Lindsay Jamieson am 17 Nov. 2016
Good to know I'm not going crazy. I did in the last few hours automate it using hold on then add the extra plots step by step with a bunch of whiles and for and switch statements layered together. I have to turn the legend off then on again to in the process. It's a bit clunky now but it looks and feels correct to a user. Thanks for answering.
dpb
dpb am 18 Nov. 2016
Presuming the overloaded plot is an m-file, there's always the expedient of munging on it. Not recommended, but sometimes making a personal copy that has desired behavior is the simplest workaround.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Exploration finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by