Plot with axis and labels with different colors [message #85321] |
Wed, 24 July 2013 10:19  |
mairan.teodoro
Messages: 20 Registered: June 2008
|
Junior Member |
|
|
Hi all,
Is there any easy way of creating a plot with the axis in white and the axis labels in black?
I have an image with black background and would like to show the tick marks in white, and the labels in black.
Thanks for any help.
m.
|
|
|
Re: Plot with axis and labels with different colors [message #85323 is a reply to message #85321] |
Wed, 24 July 2013 10:41   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mairan Teodoro writes:
> Is there any easy way of creating a plot with the axis in white and the axis labels in black?
>
> I have an image with black background and would like to show the tick marks in white, and the labels in black.
image = BytArr(300, 300)
image[50,50] = Dist(200,200)
cgLoadct, 5
cgImage, image, /Axes, color='white', OPosition=p, /Fit_Inside
cgPlot, findgen(300), /NoData, /NoErase, Position=p, XStyle=4, YStyle=4
cgPlot, findgen(300), /NoData, /NoErase, Position=p, $
XTicklen=0.0001, YTicklen=0.0001, XMinor=0, YMinor=0
END
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: Plot with axis and labels with different colors [message #85334 is a reply to message #85333] |
Thu, 25 July 2013 12:20  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Mairan Teodoro writes:
> Thanks for the suggestion. However, that's exactly the way I use to create this kind of plot (one CGIMAGE call and two CGPLOT calls).
>
> I was thinking about something like a keyword to define the color of the axis labels... something like
>
> cgPlot, dataX, dataY, axiscolor='white', axislabel='black',...
Unfortunately, the axis color and the axis label are not separated in
the underlying Plot and Axis commands in IDL. That's why you have to do
this run-around.
In object graphics, these two colors are separate, so you can do what
you like. It's rather round-about in Function Graphics, too, but it is
possible. You do it like this:
;***********************************************************
im = image(cgdemodata(7))
p = im.POSITION
p = plot(indgen(360), position=p, /current, /nodata)
axes = p.axes
for j=0,3 do axes[j].color = 'white'
for j=0,3 do axes[j].text_color = 'black'
;***********************************************************
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.")
|
|
|