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

Home » Public Forums » archive » Bar coordinate shift with cgBarPlot
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 coordinate shift with cgBarPlot [message #87738] Tue, 25 February 2014 12:51 Go to next message
Federico Tosi is currently offline  Federico Tosi
Messages: 4
Registered: February 2014
Junior Member
Hi all,

I am using Coyote's cgBarPlot to plot some vertical bars, but I'm having hard times to shift the bars of a given quantity in the horizontal direction. The BAROFFSET parameter does not do the job, because I need the bars not to be centered on a thick (i.e., I need to change their X coordinate), while BARCOORDS is an output parameter.

Is there any easy way to do that?

Thanks,
Federico
Re: Bar coordinate shift with cgBarPlot [message #87739 is a reply to message #87738] Tue, 25 February 2014 13:00 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Federico Tosi writes:

> I am using Coyote's cgBarPlot to plot some vertical bars, but I'm having hard times to shift the bars of a given quantity in the horizontal direction. The BAROFFSET parameter does not do the job, because I need the bars not to be centered on a thick (i.e., I need to change their X coordinate), while BARCOORDS is an output parameter.
>
> Is there any easy way to do that?

The easiest way is probably just to draw the darn things yourself. But,
I really don't understand what you are trying to do. :-)

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 coordinate shift with cgBarPlot [message #87744 is a reply to message #87738] Tue, 25 February 2014 14:36 Go to previous messageGo to next message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den tisdagen den 25:e februari 2014 kl. 21:51:51 UTC+1 skrev Federico Tosi:
> Hi all,
>
> I am using Coyote's cgBarPlot to plot some vertical bars, but I'm having hard times to shift the bars of a given quantity in the horizontal direction. The BAROFFSET parameter does not do the job, because I need the bars not to be centered on a thick (i.e., I need to change their X coordinate), while BARCOORDS is an output parameter.
>
> Is there any easy way to do that?

Does adding a number to the X coordinate do anything useful?
Re: Bar coordinate shift with cgBarPlot [message #87749 is a reply to message #87739] Tue, 25 February 2014 23:30 Go to previous messageGo to next message
Federico Tosi is currently offline  Federico Tosi
Messages: 4
Registered: February 2014
Junior Member
I have data separated for angle range: 0°-10°, 10°-20°, 20°-30°, 30°-40°, etc.. In the Y-coordinate is the number of observed data. When cgBarPlot is used, the vertical bars are centered on: 0°, 10°, 20°, 30°, while I would like them to be centered around: 5°, 15°, 25°, etc., so that the width of the bar is representative of the range of abscissa of my data.

I'm afraid that, when the bars are cumulative (i.e., when multiple cgBarPlot are overplotted), drawing them one by one is unfeasible.

Federico


> The easiest way is probably just to draw the darn things yourself. But,
>
> I really don't understand what you are trying to do. :-)
>
> 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 coordinate shift with cgBarPlot [message #87752 is a reply to message #87749] Wed, 26 February 2014 02:09 Go to previous messageGo to next message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Wednesday, February 26, 2014 8:30:21 AM UTC+1, Federico Tosi wrote:
> I have data separated for angle range: 0°-10°, 10°-20°, 20°-30°, 30°-40°, etc.. In the Y-coordinate is the number of observed data. When cgBarPlot is used, the vertical bars are centered on: 0°, 10°, 20°, 30°, while I would like them to be centered around: 5°, 15°, 25°, etc., so that the width of the bar is representative of the range of abscissa of my data.
>
>
>
> I'm afraid that, when the bars are cumulative (i.e., when multiple cgBarPlot are overplotted), drawing them one by one is unfeasible.
>
>
>
> Federico
>
>
>
>
>
>> The easiest way is probably just to draw the darn things yourself. But,
>
>>
>
>> I really don't understand what you are trying to do. :-)
>
>>
>
>> 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.")

I don't see a problem in doing this. If you read the documentation David has provided, then this is how I would do it: you will find two keywords you can use: barcoords and barnames (only if you want to show these).

How's this for you:
cgBarPlot, findgen(10), barcoords=findgen(10)*10.0, barnames=string(findgen(10)*10.0,format='(f0.1)')

Or if you want it centered in the middle, just change that to

cgBarPlot, findgen(10)+1.0, barcoords=findgen(10)*10.0+5.0, barnames=string(findgen(10)*10.0+5.0,format='(f0.1)')

What you have to figure out is what you give as input to cgBarPlot. If for the range 0-10 you give 0 or 10. Ideally you will want to use (low+high)/2.0. How you calculate that, depends on the input you have.

Cheers,
h
Re: Bar coordinate shift with cgBarPlot [message #87753 is a reply to message #87752] Wed, 26 February 2014 03:15 Go to previous messageGo to next message
Federico Tosi is currently offline  Federico Tosi
Messages: 4
Registered: February 2014
Junior Member
Helder,

what you suggest is a clever way to get around the problem. However, I understand that BARCOORDS is an output parameter, rather than an input one, hence I don't see how you can use BARCOORDS to determine the placement of the bars on the X axis.

Even in the two examples you suggested, there is always one tick below the bar, while I really would love the bar to be placed in between two ticks. And, I cannot draw the bars one by one. That's my real issue.

Cheers,
Federico


Il giorno mercoledì 26 febbraio 2014 11:09:30 UTC+1, Helder ha scritto:

> I don't see a problem in doing this. If you read the documentation David has provided, then this is how I would do it: you will find two keywords you can use: barcoords and barnames (only if you want to show these).
>
>
>
> How's this for you:
>
> cgBarPlot, findgen(10), barcoords=findgen(10)*10.0, barnames=string(findgen(10)*10.0,format='(f0.1)')
>
>
>
> Or if you want it centered in the middle, just change that to
>
>
>
> cgBarPlot, findgen(10)+1.0, barcoords=findgen(10)*10.0+5.0, barnames=string(findgen(10)*10.0+5.0,format='(f0.1)')
>
>
>
> What you have to figure out is what you give as input to cgBarPlot. If for the range 0-10 you give 0 or 10. Ideally you will want to use (low+high)/2.0. How you calculate that, depends on the input you have.
>
>
>
> Cheers,
>
> h
Re: Bar coordinate shift with cgBarPlot [message #87758 is a reply to message #87753] Wed, 26 February 2014 05:31 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Federico Tosi writes:

> what you suggest is a clever way to get around the problem. However, I
understand that BARCOORDS is an output parameter, rather than an input
one, hence I don't see how you can use BARCOORDS to determine the
placement of the bars on the X axis.
>
> Even in the two examples you suggested, there is always one tick below the bar, while I really would love the bar to be placed in between two ticks. And, I cannot draw the bars one by one. That's my real issue.

You are not going to be able to do anything about the ticks, but maybe
something like this will work for you:

tickNames = StrArr(5)
FOR j=0,4 DO tickNames[j] = StrTrim(j*10,2) + '-' + StrTrim(j*10+10,2)
cgBarPlot, findgen(5)+1.0, barnames=ticknames

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 coordinate shift with cgBarPlot [message #87763 is a reply to message #87758] Wed, 26 February 2014 08:52 Go to previous messageGo to next message
Federico Tosi is currently offline  Federico Tosi
Messages: 4
Registered: February 2014
Junior Member
Thanks for the reply, David. In fact this works, although it is graphically inelegant when you have many bars and they are close to each other.

I wonder whether an alternative approach could exist, perhaps removing the X-axis and redesigning it (with the AXIS command) taking care of defining the ticks. However, I'm not sure this can be done in conjunction with cgBarPlot.


> You are not going to be able to do anything about the ticks, but maybe
>
> something like this will work for you:
>
>
>
> tickNames = StrArr(5)
>
> FOR j=0,4 DO tickNames[j] = StrTrim(j*10,2) + '-' + StrTrim(j*10+10,2)
>
> cgBarPlot, findgen(5)+1.0, barnames=ticknames
>
>
>
> 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 coordinate shift with cgBarPlot [message #87764 is a reply to message #87763] Wed, 26 February 2014 09:04 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Federico Tosi writes:

> Thanks for the reply, David. In fact this works, although it is graphically inelegant when you have many bars and they are close to each other.
>
> I wonder whether an alternative approach could exist, perhaps removing the X-axis and redesigning it (with the AXIS command) taking care of defining the ticks. However, I'm not sure this can be done in conjunction with cgBarPlot.

I think I have said here several times that one of the worst programming
decisions I ever made was to do a direct translation of BarPlot to
cgBarPlot. So, yes, we have to live with our past.

If I were doing this, I would simply suppress the tick labels and add
them myself, rotated at, say, a 45 degree angle so they will fit. You
can do this with cgText. You can find code that does exactly this in the
cgBoxPlot program.

Should this feature be added to cgBarPlot. Probably. Am I going to do
it? No, not right now, unless someone is offering money. Then, I'd try
to fit it in. :-)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: how to composite a mapcoord object using geographic coordinate(no projection)
Next Topic: Setting axes range in function graphics

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

Current Time: Wed Oct 08 13:45:53 PDT 2025

Total time taken to generate the page: 0.00700 seconds