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

Home » Public Forums » archive » Trying to create a plot with strings as x-values...
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
Trying to create a plot with strings as x-values... [message #88314] Sun, 13 April 2014 19:32 Go to next message
doowstados is currently offline  doowstados
Messages: 3
Registered: April 2014
Junior Member
Please forgive my poor IDL background. Hopefully you IDL experts can help me out.

I'm attempting to create a plot with strings as x values.

I have two lists being loaded from text files in this format:

xlist = list(value1, value1, value1, value2, value2, value3, ..., valueN)

ylist = list(12, 17, 15, 13, 11.4, 19, 17, ..., numN)

These lists are fairly short, maybe 150-200 coordinate pairs total, but only around 50 unique strings in the xlist, so the program doesn't need to be particularly resource efficient.


IDL's plot function and cgPlot don't seem to get along well with strings.

Does anyone know a way around this? Thanks in advance!
Re: Trying to create a plot with strings as x-values... [message #88315 is a reply to message #88314] Sun, 13 April 2014 21:13 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
doowstados@gmail.com writes:

> Please forgive my poor IDL background. Hopefully you IDL experts can help me out.
>
> I'm attempting to create a plot with strings as x values.
>
> I have two lists being loaded from text files in this format:
>
> xlist = list(value1, value1, value1, value2, value2, value3, ..., valueN)
>
> ylist = list(12, 17, 15, 13, 11.4, 19, 17, ..., numN)
>
> These lists are fairly short, maybe 150-200 coordinate pairs total, but only around 50 unique strings in the xlist, so the program doesn't need to be particularly resource efficient.
>
>
> IDL's plot function and cgPlot don't seem to get along well with strings.

I presume these "strings" are numbers. Something like '5.2' or '3.4'. If
so, just cast them to floats before you plot them.

IDL> value = '5.3'
IDL> Help, float(value)
<Expression> FLOAT = 5.30000

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: Trying to create a plot with strings as x-values... [message #88316 is a reply to message #88315] Sun, 13 April 2014 22:18 Go to previous messageGo to next message
doowstados is currently offline  doowstados
Messages: 3
Registered: April 2014
Junior Member
Thanks for your reply!


Unfortunately, the strings are text.

I'm looking to make a plot that loosely resembles this:

5| *
4| * *
3|* * *
2| * *
1|*
0_________*_________
A B C D E

But A,B,C,D,E are strings of length 3.

listA contains the x values (strings) with some duplicates
listB contains the y values (floating point values)
Re: Trying to create a plot with strings as x-values... [message #88319 is a reply to message #88316] Mon, 14 April 2014 05:23 Go to previous messageGo to next message
Matthew Argall is currently offline  Matthew Argall
Messages: 286
Registered: October 2011
Senior Member
Something like this?

time = indgen(11)
data = randomu(0, 11)
tickvalues = [0,2,4,6,8,10]
ticknames = ['A', 'B', 'C', 'D', 'E']
cgPlot, time, data, XTICKNAME=ticknames, XTICKV=tickvalues
Re: Trying to create a plot with strings as x-values... [message #88320 is a reply to message #88316] Mon, 14 April 2014 05:33 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
doowstados@gmail.com writes:

>
> Thanks for your reply!
>
>
> Unfortunately, the strings are text.
>
> I'm looking to make a plot that loosely resembles this:
>
> 5| *
> 4| * *
> 3|* * *
> 2| * *
> 1|*
> 0_________*_________
> A B C D E
>
> But A,B,C,D,E are strings of length 3.
>
> listA contains the x values (strings) with some duplicates
> listB contains the y values (floating point values)

Maybe you are looking for some version of a dot plot:

http://www.idlcoyote.com/gallery/index.html#DOTPLOT

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: Trying to create a plot with strings as x-values... [message #88326 is a reply to message #88320] Mon, 14 April 2014 14:52 Go to previous message
doowstados is currently offline  doowstados
Messages: 3
Registered: April 2014
Junior Member
Very close! Thanks!


That would be perfect if it allowed me to swap the x and y axis and only made one of each "label" instead of repeating them like this:


5|
4| *
3|* *
2| *
1| * * * *
0__________________
A A B B B C D E

If that makes sense. I think I can tinker with it to make it work, though.

Thanks!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Contour value in each point in XY plane
Next Topic: BarCoords- cgBarplot

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

Current Time: Wed Oct 08 09:15:57 PDT 2025

Total time taken to generate the page: 0.00586 seconds