X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



5786 Rate this article:
No rating

Example of changing size, thickness, and font of Object Graphics axis titles and tickmark text


How can I change the size, thickness, and font of Object Graphics axis titles and tickmark text?

First create axis titles as text objects (IDLgrText objects). Use the SetProperty method to the axis object (IDLgrAxis object) to set the Title property equal to the text object. Use the GetProperty method to get the TickText property which is an instance of an IDLgrText object containing a vector of text strings.

To change the type style or size of the "title" or "tick text" text objects, create a font object (IDLgrFont object) and use the SetProperty method to the axis text object to specify the font and the type size.

The following code selects the times*bold eight point font for the axes title and tickmark text objects:
pro example_axis
data = findgen(100)
myplot = OBJ_NEW('IDLgrPlot', data)
xaxis = OBJ_NEW('IDLgrAxis', 0)
yaxis = OBJ_NEW('IDLgrAxis', 1)

; Retrieve the data range from the plot object and set the X and Y
; axis objects' RANGE properly so that the axes will match the data
; when displayed:
myplot -> GetProperty, XRANGE=xr, YRANGE=yr
xaxis -> SetProperty, RANGE=xr
yaxis -> SetProperty, RANGE=yr

; By default, major tickmarks are 0.2 data units in length. Since
; the data range in this example is 0 to 99, we set the tick length
; to 2% of the data range instead:
xtl = 0.02 * (xr[1] - xr[0])
ytl = 0.02 * (yr[1] - yr[0])
xaxis -> SetProperty, TICKLEN=xtl
yaxis -> SetProperty, TICKLEN=ytl
xaxis_text = OBJ_NEW('IDLgrText','X Axis')
yaxis_text = OBJ_NEW('IDLgrText','Y Axis')
myfont = OBJ_NEW('IDLgrFont','times*bold',size=8)
xaxis_text->SetProperty, font=myfont
yaxis_text->SetProperty, font=myfont
xaxis->SetProperty, TITLE = xaxis_text
yaxis->SetProperty, TITLE = yaxis_text
;
xaxis->GetProperty, TICKTEXT = xtick_text
yaxis->GetProperty, TICKTEXT = ytick_text
xtick_text->SetProperty, font=myfont
ytick_text->SetProperty, font=myfont

; Create model and view objects to contain the object tree, and
; a window object to display it:
mymodel = OBJ_NEW('IDLgrModel')
myview = OBJ_NEW('IDLgrView')
; use a viewgroup so that the heap will be cleaned up
; when the window is closed
mygroup= OBJ_NEW('IDLgrViewgroup')
mygroup->add, [myview, xaxis_text, yaxis_text, myfont]
mywindow = OBJ_NEW('IDLgrWindow', RETAIN=2, GRAPHICS_TREE=mygroup)
mymodel -> Add, myplot
mymodel -> Add, xaxis
mymodel -> Add, yaxis
myview -> Add, mymodel

; Use the SET_VIEW procedure to add an appropriate viewplane rectangle
; to the view object.
SET_VIEW, myview, mywindow

; Now, display the plot:
mywindow -> Draw
end
Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »