Clear Filters
Clear Filters

Creating presentable log y-scale graph when occasional tiny values exist

4 views (last 30 days)
Hello,
I'm attempting to write a script that automates time-series figures for very large datasets with a log-y scale. I'm plotting basic stats: min, mean and max. In these time series, occasional very small minima occur that end up making the graph look horrible. I would just adjust the y-axis scale post-facto, but since I'm hoping to generate dozens of figures at a time, this is not a plausible solution. Consider the following dummy script:
time = [1:30]
mean = 1000*rand(1,30)
max = 10000*rand(1,30)
min = rand(1,30)
min(10:13)= 0.000001
min(23:26)= 0.000001
set(gca, 'yscale','log')
hold
plot(time,mean)
plot(time,max,'k')
plot(time,min,'r')
Any ides on how to handle my graph so that these 0.000001 values don't make my figure look awful? The time series data I'm playing with area over the place with scales of their own, so setting a fixed lower y-axis limit doesn't work.
I was hoping to simply grab the lower y-axis value prior to plotting the minimum values and resetting this as the lower limit after graphing the minima, but can't seem to figure out how to determine the axis boundaries (or tick marks) from an existing plot...
Thanks, Ryan

Answers (1)

Walter Roberson
Walter Roberson on 24 Jan 2012
Please do not call a variable "min" "max" or "mean" -- you will create problems for yourself because those names or functions that are commonly used in MATLAB programs.
The basic solution to your problem is to use max() in the sense of the MATLAB function (the one not accessible because you wrote a variable with the same name.) So if I rename your variables MinData and MaxData,
MinData = max(SomeLowerBound, MinData);
MaxData = max(SomeLowerBound, MaxData);
SomeLowerBound is the smallest value whose log you would not mind appearing on your plot.

Categories

Find more on Formatting and Annotation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!