comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Bar plotting in IDL
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Bar plotting in IDL [message #87263] Wed, 22 January 2014 06:57 Go to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Hello,

I wanted to make a bar plot in IDL and attempted the following lines with some synthetic data:
-------------------------------
PRO Bar_test

xnos=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21, 22,23,24,25, $
26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46, 47,48, $
49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68, 69,70, $
71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90, 91,92, $
93,94,95,96,97,98,99,100]
ydata=[14,2,1,0,3,10,1,0,3,4,4,5,!VALUES.F_NAN,1,13,13,8,3,3 ,1,1,0,0,0, $
0,2,2,0,2,3,1,0,1,1,0,1,2,6,2,7,5,2,3,0,6,1,1,3,3,4,0,2,5,3, 5,6, $
10,0,9,6,7,!VALUES.F_NAN,7,!VALUES.F_NAN,!VALUES.F_NAN, $
7,!VALUES.F_NAN,7,13,12,9,3,2,0,0,3,4,!VALUES.F_NAN,2,2,3, $
5,!VALUES.F_NAN,1,3,3,!VALUES.F_NAN,1,2,5,5,4,2,2,4,4,12, $
!VALUES.F_NAN,90]

Filename='test.ps'

cgPS_Open,Filename

cgDisplay,1200,1000

xtickv=[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85, 90,95,100]

cgPlot,xnos,ydata,XTicks=20,XTickV=xtickv, $
Position=[0.1,0.5,0.9,0.9],/NoData

cgBarPlot,ydata,BARCOORDS=xnos,XStyle=1, $
XTitle=xtitle4,YTitle=ytitle4,Font=-1, $
YRange=[0,100],XRange=[0,100], $
colors=['cornflower blue'],/Overplot

cgPS_Close

cgPS2Raster,Filename,/PNG, Width=1000

END
------------------------

I get the error as below:

(1) CGAXIS -> Keyword array parameter XTICKNAME must have from 1 to 60 elements.

(2) I get the figure with bars but I don't see my xnos or x-axis labels are matching with my xnos. For example, the last value of ydata is 90 and the bar for this value is shown at an xnos=94.

My understanding for using bar plot may be wrong!!! Can anyone help me resolve the issues I am facing?

Thanks in advance ...
Re: Bar plotting in IDL [message #87267 is a reply to message #87263] Wed, 22 January 2014 07:30 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
> cgBarPlot,ydata,BARCOORDS=xnos,XStyle=1, $
> XTitle=xtitle4,YTitle=ytitle4,Font=-1, $
> YRange=[0,100],XRange=[0,100], $
> colors=['cornflower blue'],/Overplot

> (1) CGAXIS -> Keyword array parameter XTICKNAME must have from 1 to 60 elements.

The BARCOORDS keyword is the value or name of each bar on your barplot. The bars are labelled with the XTICKNAME to cgAxis. IDL only allows up to 60 tick names while your "xnos" variable has more than 60 elements. Try picking a smaller subset of your data so that data points are binned into the bars. Otherwise each bar will have exactly 1 data point in it.

(also, try xnos = indgen(100)+1)


> (2) I get the figure with bars but I don't see my xnos or x-axis labels are matching with my xnos. For example, the last value of ydata is 90 and the bar for this value is shown at an xnos=94.

I expect that fixing the first issue will fix this one too.
Re: Bar plotting in IDL [message #87269 is a reply to message #87263] Wed, 22 January 2014 07:33 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> I get the error as below:
>
> (1) CGAXIS -> Keyword array parameter XTICKNAME must have from 1 to 60 elements.
>
> (2) I get the figure with bars but I don't see my xnos or x-axis labels are matching with my xnos. For example, the last value of ydata is 90 and the bar for this value is shown at an xnos=94.
>
> My understanding for using bar plot may be wrong!!! Can anyone help me resolve the issues I am facing?

You are running into the same problem you ran into yesterday. IDL has a
limitation on the number of labels it can put on an axis (60
apparently). Each bar plot uses a label in this code.

I think I would try to write something like the Error Estimate Plot in
the Coyote Plot Gallery, where instead of plotting errors you plot the
median value with the quadrilles on either side of it. Not sure what you
should do with outliers in that case, but maybe they don't matter.

Or, I suppose you can try overplotting no more than 60 values at a time
on the plot. The code is pretty clunky. It was a direct port of the IDL
routine. But, it is possible to do some nice things with it.

http://www.idlcoyote.com/cg_tips/barplot.php

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Bar plotting in IDL [message #87271 is a reply to message #87269] Wed, 22 January 2014 07:46 Go to previous messageGo to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
> You are running into the same problem you ran into yesterday. IDL has a
> limitation on the number of labels it can put on an axis (60
> apparently). Each bar plot uses a label in this code.
>
> I think I would try to write something like the Error Estimate Plot in
> the Coyote Plot Gallery, where instead of plotting errors you plot the
> median value with the quadrilles on either side of it. Not sure what you
> should do with outliers in that case, but maybe they don't matter.

I have already tried this idea of plotting median values instead of mean values and quartile_25 and quartile_75 values for errorbars. I need to identify the outliers for each time-step and then flag that particular value or to say if there were more outliers from a single station data then I shall flag that station data. I have already done this and fine with my approach.

> Or, I suppose you can try overplotting no more than 60 values at a time
> on the plot. The code is pretty clunky. It was a direct port of the IDL
> routine. But, it is possible to do some nice things with it.

The above data is just the serial numbers of station numbers (xnos) and corresponding percent of outliers from the whole dataset of that particular station. In this case, I have 99 stations and I just wanted to visualize the bars to distinguish the station that is providing with most outlier data. Hence, I wanted to use the bar plot for more xtickvalues. I don't know how I can change this limitation in cgBarplot.pro.

Thanks for your suggestions ...
Re: Bar plotting in IDL [message #87272 is a reply to message #87271] Wed, 22 January 2014 07:55 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Madhavan Bomidi writes:

> The above data is just the serial numbers of station numbers (xnos) and corresponding percent of outliers from the whole dataset of that particular station. In this case, I have 99 stations and I just wanted to visualize the bars to distinguish the station that is providing with most outlier data. Hence, I wanted to use the bar plot for more xtickvalues. I don't know how I can change this limitation in cgBarplot.pro.

The limitation is in IDL, not in cgBarPlot.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Bar plotting in IDL [message #87275 is a reply to message #87272] Wed, 22 January 2014 07:58 Go to previous messageGo to next message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Thanks for the info.

On Wednesday, January 22, 2014 4:55:27 PM UTC+1, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> The above data is just the serial numbers of station numbers (xnos) and corresponding percent of outliers from the whole dataset of that particular station. In this case, I have 99 stations and I just wanted to visualize the bars to distinguish the station that is providing with most outlier data. Hence, I wanted to use the bar plot for more xtickvalues. I don't know how I can change this limitation in cgBarplot.pro.
>
>
>
> The limitation is in IDL, not in cgBarPlot.
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Bar plotting in IDL [message #87277 is a reply to message #87272] Wed, 22 January 2014 08:13 Go to previous messageGo to next message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
On Wednesday, January 22, 2014 9:55:27 AM UTC-6, David Fanning wrote:
> Madhavan Bomidi writes:
>
>
>
>> The above data is just the serial numbers of station numbers (xnos) and corresponding percent of outliers from the whole dataset of that particular station. In this case, I have 99 stations and I just wanted to visualize the bars to distinguish the station that is providing with most outlier data. Hence, I wanted to use the bar plot for more xtickvalues. I don't know how I can change this limitation in cgBarplot.pro.
>
>
>
> The limitation is in IDL, not in cgBarPlot.
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")


And I would argue a reasonable limitation. I can't imagine plotting 99 stations -all one on plot, all labelled- would be very visually appealing.

Regardless, why force a square peg into a round hole? If you're just trying visualize, just make two plot - one for stations 1-49 and the other 50-99? Wouldn't this be the quickest and easiest solution?
Re: Bar plotting in IDL [message #87287 is a reply to message #87277] Thu, 23 January 2014 01:07 Go to previous message
atmospheric physics is currently offline  atmospheric physics
Messages: 121
Registered: June 2010
Senior Member
Thanks Philip for your intelligent suggestion.


On Wednesday, January 22, 2014 5:13:57 PM UTC+1, Phillip Bitzer wrote:
> On Wednesday, January 22, 2014 9:55:27 AM UTC-6, David Fanning wrote:
>
>> Madhavan Bomidi writes:
>
>>
>
>>
>
>>
>
>>> The above data is just the serial numbers of station numbers (xnos) and corresponding percent of outliers from the whole dataset of that particular station. In this case, I have 99 stations and I just wanted to visualize the bars to distinguish the station that is providing with most outlier data. Hence, I wanted to use the bar plot for more xtickvalues. I don't know how I can change this limitation in cgBarplot.pro.
>
>>
>
>>
>
>>
>
>> The limitation is in IDL, not in cgBarPlot.
>
>>
>
>>
>
>>
>
>> Cheers,
>
>>
>
>>
>
>>
>
>> David
>
>>
>
>> --
>
>>
>
>> David Fanning, Ph.D.
>
>>
>
>> Fanning Software Consulting, Inc.
>
>>
>
>> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
>>
>
>> Sepore ma de ni thue. ("Perhaps thou speakest truth.")
>
>
>
>
>
> And I would argue a reasonable limitation. I can't imagine plotting 99 stations -all one on plot, all labelled- would be very visually appealing.
>
>
>
> Regardless, why force a square peg into a round hole? If you're just trying visualize, just make two plot - one for stations 1-49 and the other 50-99? Wouldn't this be the quickest and easiest solution?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Plotting points in fainter color on an IDL plot
Next Topic: binning a point clouds in the xy plane

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:42:41 PDT 2025

Total time taken to generate the page: 0.00505 seconds