Trying to create a plot with strings as x-values... [message #88314] |
Sun, 13 April 2014 19:32  |
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   |
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 #88319 is a reply to message #88316] |
Mon, 14 April 2014 05:23   |
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 #88326 is a reply to message #88320] |
Mon, 14 April 2014 14:52  |
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!
|
|
|