Hi Mark,
If you specify the string when you create the Plot() it will take the font name and colour as specified there:
myplot = plot(mydata_x, $
mydata_y, $
font_name=plotfont, $
font_color=mycolor, $
title = 'Plot Title')
It seems that if you specify it as you did, the font_name and font_color are not saved as "defaults", they just apply to
things created in that command. However, if the title needs to wait until the Plot() is created, two options:
myplot.title = Text(0.5, 0.9, 'Plot Title', alignment=0.5, font_name = 'Courier', color = [255,0,0])
... and you'd have to fuss with the text size, get the position right, etc.
myplot.title = 'Plot Title' ; A just-right TEXT object is created from this
myplot.title.font_name = 'Courier'
myplot.title.color = [255,0,0]
If you see unwanted flickering through those changes, you can do this:
myplot.refresh, /disable
myplot.title = 'Plot Title'
myplot.title.font_name = 'Courier'
myplot.title.color = [255,0,0]
myplot.refresh
Hope this helps!
--
Cheers,
-Dick
Dick Jackson Software Consulting Inc.
Victoria, BC, Canada
www.d-jackson.com
superchromix wrote, On 2014-10-29, 9:24am:
>
> hi,
>
> I am making a foray into function graphics programming and I have uncovered what I think is a bug in the way that the properties of the plot title are set.
>
> Essentially, when you create the plot, if you request a certain font, or font color, these properties are applied to the axis fonts but not the font title. This is contrary to what is specified in the IDL documentation for the PLOT function:
>
> -------------------
> TITLE
> Set this property to a string specifying a title. The title properties may be modified using FONT_COLOR, FONT_NAME, FONT_SIZE, and FONT_STYLE. After creation the TITLE property may be used to retrieve a reference to the title text object, and the TEXT properties may be used to modify the title object.
> -------------------
>
>
> The bug is demonstrated in the following test case:
>
> ;----
> pro test_plot_title_font
>
> mydata_x = indgen(100)
> mydata_y = sin(mydata_x * !pi/25.0)
>
> plotfont = 'Courier'
> mycolor = [255,0,0]
>
> myplot = plot(mydata_x, $
> mydata_y, $
> font_name=plotfont, $
> font_color=mycolor)
>
> myplot.title = 'Plot Title'
>
> ax = myplot.axes
> ax[0].title = 'X axis'
> ax[1].title = 'Y axis'
>
> mytitle = myplot.title
>
> print, 'Test results:'
> print, ''
> print, 'Requested font: ', plotfont
> print, 'X axis font: ', ax[0].tickfont_name
> print, 'Y axis font: ', ax[1].tickfont_name
> print, 'Plot title font: ', mytitle.font_name
> print, ''
> print, 'Requested font color: ', mycolor
> print, 'X axis font color: ', ax[0].text_color
> print, 'Y axis font color: ', ax[1].text_color
> print, 'Plot title font color: ', mytitle.font_color
>
> print, !version
>
> end
> ;---
>
> program output:
>
> Test results:
>
> Requested font: Courier
> X axis font: Courier
> Y axis font: Courier
> Plot title font: Helvetica
>
> Requested font color: 255 0 0
> X axis font color: 255 0 0
> Y axis font color: 255 0 0
> Plot title font color: 0 0 0
> { x86_64 Win32 Windows Microsoft Windows 8.3 Nov 15 2013 64 64}
>
> As you can see, the plot title doesn't get assigned the correct font name or font color - possibly other properties would also not be properly assigned. I am using IDL 8.3 x64 on Windows. Perhaps the bug has been fixed in version 8.4?
>
> Mark
>
|