A Peak in y-axis dwarfing the other plot points

Hello all,
I have a problem in a MATLAB plot regarding a peak value in y-axis. The plot looks like in the Fig 1. But I don't want my plot to scale the y-axis to that one peak value anomaly. I want MATLAB to scale the y-asis according to the rest of the value in the plot as shown in Fig.2 (Fig.2 is the plot after removing that peak value anomaly). Can anyone please help me in this?
Peak.jpg
Without_peak.jpg

 Accepted Answer

dpb
dpb on 29 Jul 2019
Edited: dpb on 29 Jul 2019
You have basically one of three choices --
  1. Set ylim where you want it and let the rest of the graph go off the top and not be shown,
  2. Use log y axis to bring scaling of disparate ranges into view, or
  3. Use two y axes and plot on two y-axis ranges on the LH and RH to show the whole thing.
The last of the above may not be too pleasing owing to one x axis; you might find using two subplots better if choose that route.
I guess there is a fourth option -- find another graph to plot that is better behaved! :)

5 Comments

Thank you very much for the possible solutions :) I am satisfied with the ylim solution. And the graph is an adaptive algorithm where the output plot converges to the reference plot. So initial values is way off the radar and it perfectly converges after that. But still I am trying to make that initial spike less gargantuan. :) Once again thank you very much for the solutions :)
OK, make sense when explained.
You can set the
hAx=gca;
hAx.YLimMode='manual';
when creating the graph to stop Matlab from auto-ranging initially and then the line won't actually show up until gets into the range you set...but you will then see the magnitudes of interest.
Or, you could monitor magnitude while converging and occasionally rescale based on that and keep everything in view and at an appropriate scale factor as go...
You could use isoutlier to identify when your data is in a "reasonable" range of Y values and use bounds on the non-outlier data to determine your Y limits, or you could rmoutliers those outliers at the start of your data before plotting.
I'm guessing this is being plotted dynamically during the iteration phase so there really aren't outliers in that sense as the system evolves...
@Steven Lord and dpb Thank you for the suggestions.

Sign in to comment.

More Answers (0)

Categories

Tags

Community Treasure Hunt

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

Start Hunting!