Discussion:
Is there a way to plot with axis breaks in IDL?
(too old to reply)
fututre.keyboard
2010-04-02 03:28:36 UTC
Permalink
I know this is rare when you need to do this kinda plot. But i'd
appreciate a lot if someone can point me to the right direction.
Thanks!

BTW: here is an example of axis break plot from Originlab's webpage.
http://www.originlab.com/index.aspx?s=8&lm=114&pid=1020
mankoff
2010-04-02 03:57:41 UTC
Permalink
Post by fututre.keyboard
I know this is rare when you need to do this kinda plot. But i'd
appreciate a lot if someone can point me to the right direction.
Thanks!
BTW: here is an example of axis break plot from Originlab's webpage.http://www.originlab.com/index.aspx?s=8&lm=114&pid=1020
Two plot commands with various combinations of POSITION and YSTYLE
keywords. Perhaps some use of the AXIS command. Then, PLOTS to draw
the four "/" symbols.

-k.
Dave Poreh
2010-04-02 12:34:05 UTC
Permalink
Post by mankoff
Post by fututre.keyboard
I know this is rare when you need to do this kinda plot. But i'd
appreciate a lot if someone can point me to the right direction.
Thanks!
BTW: here is an example of axis break plot from Originlab's webpage.http://www.originlab.com/index.aspx?s=8&lm=114&pid=1020
Two plot commands with various combinations of POSITION and YSTYLE
keywords. Perhaps some use of the AXIS command. Then, PLOTS to draw
the four "/" symbols.
  -k.
I am also very interested.
I think David could write an article about that!
Cheers
D.
David Fanning
2010-04-02 13:12:57 UTC
Permalink
Post by Dave Poreh
I am also very interested.
I think David could write an article about that!
Or, somebody who needs the functionality can do it
and write it up, and I would publish it for them! :-)

I've made plots like this before. It is not particularly
difficult to do *a* plot. It is more difficult to write
this kind of functionality in a general way.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
mankoff
2010-04-03 18:21:03 UTC
Permalink
Post by David Fanning
I've made plots like this before. It is not particularly
difficult to do *a* plot. It is more difficult to write
this kind of functionality in a general way.
I think I just came up with a fairly generic implementation here:
http://code.google.com/p/kdm-idl/source/browse/trunk/plotbreak.pro

For example I was able to produce the following graphic (including
equivalent of OPLOT command) with the following two lines of code.
Loading Image...

plotbreak, time, p, $
position=pos, $
xrange0=[0,1000], $
xrange1=[1000,3000], $
breakpct=66, $
key0={ytitle:'Population (Phytoplankton)', $
xtitle:'Time (days)', $
xtickn:['0','20','40','60','80',' '],$
title:'Predator v. Prey', $
thick:2}, $
key1={xtitle:'Time (days)', $
yst:5,thick:2,$
xtickn:['100','150','200','250','300'] }

plotbreak, time, z, $
position=pos, $
breakpct=66, $
xrange0=[0,1000], $
xrange1=[1000,3000], $
key0={NOERASE:1,color:253,thick:3,yst:5,xst:5}, $
key1={color:253,thick:3,xst:5,$
ytitle:'Population (Zooplankton)'}



A truly generic algorithm, which would be difficult, would be
recursive and let me specify BREAKPCT=[10,30,80,90,95] rather than
just as a single percentage (66% in the above example). It should also
be recursive in X and Y. That algorithm, when complete, could then
easily be used to draw, for example, a calendar with the weekends
(first and last column) thinner than the middle weekdays. I'll leave
that as an exercise to the reader.

-k.
mankoff
2010-04-07 16:08:34 UTC
Permalink
Post by David Fanning
I've made plots like this before. It is not particularly
difficult to do *a* plot. It is more difficult to write
this kind of functionality in a general way.
I think I just came up with a fairly generic implementation here:http://code.google.com/p/kdm-idl/source/browse/trunk/plotbreak.pro
For example I was able to produce the following graphic (including
equivalent of OPLOT command) with the following two lines of code.http://kenmankoff.com/tmp/plotbreak.png
  plotbreak, time, p, $
             position=pos, $
             xrange0=[0,1000], $
             xrange1=[1000,3000], $
             breakpct=66, $
             key0={ytitle:'Population (Phytoplankton)', $
                   xtitle:'Time (days)', $
                   xtickn:['0','20','40','60','80',' '],$
                   title:'Predator v. Prey', $
                   thick:2}, $
             key1={xtitle:'Time (days)', $
                   yst:5,thick:2,$
                   xtickn:['100','150','200','250','300'] }
  plotbreak, time, z, $
             position=pos, $
             breakpct=66, $
             xrange0=[0,1000], $
             xrange1=[1000,3000], $
             key0={NOERASE:1,color:253,thick:3,yst:5,xst:5}, $
             key1={color:253,thick:3,xst:5,$
                   ytitle:'Population (Zooplankton)'}
A truly generic algorithm, which would be difficult, would be
recursive and let me specify BREAKPCT=[10,30,80,90,95] rather than
just as a single percentage (66% in the above example). It should also
be recursive in X and Y. That algorithm, when complete, could then
easily be used to draw, for example, a calendar with the weekends
(first and last column) thinner than the middle weekdays. I'll leave
that as an exercise to the reader.
  -k.
Not sure if anyone has downloaded this but I found some bugs and fixed
them. I also changed key0 and key1 keywords to be _EXTRA_0 and
_EXTRA_1 to be more 'standard'.

Simpler examples of usage than originally provided, that I think
demonstrate generality, are:

x = dindgen(51)
IDL> plotbreak, x, exp(x)
IDL> plotbreak, x, exp(x), breakpct=10
IDL> plotbreak, x, exp(x), breakpct=90

IDL> plotbreak, x, exp(-x), breakpct=10
IDL> plotbreak, x, exp(-x), breakpct=90
IDL> plotbreak, x, exp(-x), breakpct=90, _EXTRA_1={xticks:1}

IDL> plotbreak, x, -exp(-x), breakpct=90, _EXTRA_1={xticks:1}
IDL> plotbreak, x, -exp(x), breakpct=10, _EXTRA_0={xticks:1}

And of course sine waves and random functions all appear to work well
with this algorithm.

I won't post further updates here. The program (and code library) have
RSS feeds if you are interested in more...

-k.
fututre.keyboard
2010-04-08 07:33:48 UTC
Permalink
Thanks for the implementation. It takes only a little tweak to make
the plot useful. What I need to pay attention when tweaking are the
tick- related stuff. The other thing is that I have to suppress the x-
title/title and use xyouts to get a centered x-title/title. Although I
don't need to break up y-axis, I would imagine a hard time to xyouts y-
title in a usual orientation.

E
Post by David Fanning
I've made plots like this before. It is not particularly
difficult to do *a* plot. It is more difficult to write
this kind of functionality in a general way.
I think I just came up with a fairly generic implementation here:http://code.google.com/p/kdm-idl/source/browse/trunk/plotbreak.pro
For example I was able to produce the following graphic (including
equivalent of OPLOT command) with the following two lines of code.http://kenmankoff.com/tmp/plotbreak.png
  plotbreak, time, p, $
             position=pos, $
             xrange0=[0,1000], $
             xrange1=[1000,3000], $
             breakpct=66, $
             key0={ytitle:'Population (Phytoplankton)', $
                   xtitle:'Time (days)', $
                   xtickn:['0','20','40','60','80',' '],$
                   title:'Predator v. Prey', $
                   thick:2}, $
             key1={xtitle:'Time (days)', $
                   yst:5,thick:2,$
                   xtickn:['100','150','200','250','300'] }
  plotbreak, time, z, $
             position=pos, $
             breakpct=66, $
             xrange0=[0,1000], $
             xrange1=[1000,3000], $
             key0={NOERASE:1,color:253,thick:3,yst:5,xst:5}, $
             key1={color:253,thick:3,xst:5,$
                   ytitle:'Population (Zooplankton)'}
A truly generic algorithm, which would be difficult, would be
recursive and let me specify BREAKPCT=[10,30,80,90,95] rather than
just as a single percentage (66% in the above example). It should also
be recursive in X and Y. That algorithm, when complete, could then
easily be used to draw, for example, a calendar with the weekends
(first and last column) thinner than the middle weekdays. I'll leave
that as an exercise to the reader.
  -k.
mankoff
2010-04-08 17:26:19 UTC
Permalink
Post by fututre.keyboard
Thanks for the implementation. It takes only a little tweak to make
the plot useful. What I need to pay attention when tweaking are the
tick- related stuff. The other thing is that I have to suppress the x-
title/title and use xyouts to get a centered x-title/title. Although I
don't need to break up y-axis, I would imagine a hard time to xyouts y-
title in a usual orientation.
E
TITLE and XTITLE are now handled correctly (I think). I'm not sure
what you mean when you mention y-title and orientation.

Feel free to follow up with me off-list.

-k.
fututre.keyboard
2010-04-08 20:13:56 UTC
Permalink
Great. Thanks! I didn't notice the changes in the code. I just noticed
that there is an orientation keyword for xyouts. I am happy now.
Post by mankoff
Post by fututre.keyboard
Thanks for the implementation. It takes only a little tweak to make
the plot useful. What I need to pay attention when tweaking are the
tick- related stuff. The other thing is that I have to suppress the x-
title/title and use xyouts to get a centered x-title/title. Although I
don't need to break up y-axis, I would imagine a hard time to xyouts y-
title in a usual orientation.
E
TITLE and XTITLE are now handled correctly (I think). I'm not sure
what you mean when you mention y-title and orientation.
Feel free to follow up with me off-list.
   -k.
mankoff
2010-04-08 22:03:32 UTC
Permalink
Post by fututre.keyboard
Great. Thanks! I didn't notice the changes in the code. I just noticed
that there is an orientation keyword for xyouts. I am happy now.
Post by fututre.keyboard
Thanks for the implementation. It takes only a little tweak to make
the plot useful. What I need to pay attention when tweaking are the
tick- related stuff. The other thing is that I have to suppress the x-
title/title and use xyouts to get a centered x-title/title. Although I
don't need to break up y-axis, I would imagine a hard time to xyouts y-
title in a usual orientation.
E
I think I know what you're talking about. You might want to set !
fancy=1 in a startup file.
biophys
2010-04-11 07:17:13 UTC
Permalink
I recall I did something without using xyouts years ago when I was TA-
ing a physics class. It can do multiple breaks along both x and y axis
as well as overplot etc. I can dig it out from my old hard drive if
people are interested.

Cheers,
Yun
Post by fututre.keyboard
Thanks for the implementation. It takes only a little tweak to make
the plot useful. What I need to pay attention when tweaking are the
tick- related stuff. The other thing is that I have to suppress the x-
title/title and use xyouts to get a centered x-title/title. Although I
don't need to break up y-axis, I would imagine a hard time to xyouts y-
title in a usual orientation.
E
Post by David Fanning
I've made plots like this before. It is not particularly
difficult to do *a* plot. It is more difficult to write
this kind of functionality in a general way.
I think I just came up with a fairly generic implementation here:http://code.google.com/p/kdm-idl/source/browse/trunk/plotbreak.pro
For example I was able to produce the following graphic (including
equivalent of OPLOT command) with the following two lines of code.http://kenmankoff.com/tmp/plotbreak.png
  plotbreak, time, p, $
             position=pos, $
             xrange0=[0,1000], $
             xrange1=[1000,3000], $
             breakpct=66, $
             key0={ytitle:'Population (Phytoplankton)', $
                   xtitle:'Time (days)', $
                   xtickn:['0','20','40','60','80',' '],$
                   title:'Predator v. Prey', $
                   thick:2}, $
             key1={xtitle:'Time (days)', $
                   yst:5,thick:2,$
                   xtickn:['100','150','200','250','300'] }
  plotbreak, time, z, $
             position=pos, $
             breakpct=66, $
             xrange0=[0,1000], $
             xrange1=[1000,3000], $
             key0={NOERASE:1,color:253,thick:3,yst:5,xst:5}, $
             key1={color:253,thick:3,xst:5,$
                   ytitle:'Population (Zooplankton)'}
A truly generic algorithm, which would be difficult, would be
recursive and let me specify BREAKPCT=[10,30,80,90,95] rather than
just as a single percentage (66% in the above example). It should also
be recursive in X and Y. That algorithm, when complete, could then
easily be used to draw, for example, a calendar with the weekends
(first and last column) thinner than the middle weekdays. I'll leave
that as an exercise to the reader.
  -k.
mankoff
2010-04-12 17:11:59 UTC
Permalink
Post by biophys
I recall I did something without using xyouts years ago when I was TA-
ing a physics class. It can do multiple breaks along both x and y axis
as well as overplot etc. I can dig it out from my old hard drive if
people are interested.
Cheers,
Yun
I'm interested.

-k.
biophys
2010-04-28 02:45:38 UTC
Permalink
Ok, for those who are interested. I finally had sometime to hook up
one of those old ide drives and dig out the file.

I added a new idldoc comment header in rst format and fixed a "ghost"
problem with PS output. Basically I use a plot command with no breaks
to determine the plot region and generate proper (x/y) titles. Then I
have to erase the plot except those titles with another plot using
background color. It works perfect for direct graphics but there will
be "ghost" tick labels in PS output due to none perfect overlapping. I
fixed it by patching with small background filled rectangles. It is
not elegant but works for me so far.

Another issue is that ticklen can be very different when you have
uneven plotting segments. It seems that the ticklen is proportional to
the size of the plotting segment. I can scale the (major) ticklen with
xticklen/yticklen keyword(s). However, the minor ticks does not scale
accordingly.

Please visit the following site for source and documents and feel free
to mature the code as you see fit. I am not sure how long this server
will last since my boss had got another job a while ago. It would be
nice someone can help hosting the file. Comments and suggestions are
definitely welcome.

http://tinyurl.com/2aflnn2

Best,
Yun
Post by mankoff
Post by biophys
I recall I did something without using xyouts years ago when I was TA-
ing a physics class. It can do multiple breaks along both x and y axis
as well as overplot etc. I can dig it out from my old hard drive if
people are interested.
Cheers,
Yun
I'm interested.
  -k.
David Fanning
2010-04-28 03:00:55 UTC
Permalink
Post by biophys
I added a new idldoc comment header in rst format and fixed a "ghost"
problem with PS output. Basically I use a plot command with no breaks
to determine the plot region and generate proper (x/y) titles. Then I
have to erase the plot except those titles with another plot using
background color. It works perfect for direct graphics but there will
be "ghost" tick labels in PS output due to none perfect overlapping. I
fixed it by patching with small background filled rectangles. It is
not elegant but works for me so far.
It might be easier to "draw" the plot with invisible ink.
Here is the Plot command I usually use:

Plot, xrange, yrange, POSITION=position, $
XSTYLE=5, YSTYLE=21, /NODATA, /NOERASE

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
biophys
2010-04-28 04:17:00 UTC
Permalink
Hi, David

Suppressing the entire axis would also erase the xtitle/ytitle. That's
what bothers me. I wanted it to be consistent when there is no breaks
at all. It may look like an overkill with this not so elegant
solution. Afterall, one could always use xyouts to draw the xtitle/
ytitle and fine tune the positions and charsize.

Best,
Yun
Post by David Fanning
Post by biophys
I added a new idldoc comment header in rst format and fixed a "ghost"
problem with PS output. Basically I use a plot command with no breaks
to determine the plot region and generate proper (x/y) titles. Then I
have to erase the plot except those titles with another plot using
background color. It works perfect for direct graphics but there will
be "ghost" tick labels in PS output due to none perfect overlapping. I
fixed it by patching with small background filled rectangles. It is
not elegant but works for me so far.
It might be easier to "draw" the plot with invisible ink.
      Plot, xrange, yrange, POSITION=position, $
        XSTYLE=5, YSTYLE=21, /NODATA, /NOERASE
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming:http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Loading...