Hello,
I was attempting to make 2 plots in 1 column using !P.Multi=[0,1,2]. My intention was to obtain: (1) top panel plot - Error estimation plot with mean, standard deviation as background and min-max as boundaries for a time-series data of a variable, (2) below panel plot - Bar plot showing the frequency of observations respectively at each time-step corresponding to the above plot. I started using the examples of colored line plots (for two row plotting), Error-estimate plot (for top panel plot), and Bar plot without errorbars (for below panel plot).
I made the following code, which is resulting in crazy errors and the plots are exchanging their positions (i.e., top panel <-> below panel). I got an error for bar plot as "CgAxis - Keyword array parameter XTICKNAME must have from 1 to 60 elements". I don't have any clue where I am actually going wrong, probably I have not understood properly the Coyote's library graphic routines. Can someone provide me assistance to achieve my desired plot?
; --------------------------------
PRO Test_Plot
CLOSE,/ALL
; **** Input Data [80800 data points each] ****
xtime=jultime ; X-axis
var_data=mean_values ; Variable mean values
var_std=std_values ; Variable standard deviation values
high_error=var_data + var_std ; Upper error
low_error=var_data - var_std ; Lower error
var_min=min_values ; Variable minimum values
var_max=max_values ; Variable maximum values
npoints=var_count ; No. of points used
; Setup variables for the plot
xtitle = 'Julian Time'
ytitle1 = 'Variable'
ytitle2 = 'Counts'
title = 'Test Plot'
position1 = [0.15, 0.15, 0.90, 0.50]
position2 = [0.15, 0.52, 0.90, 0.90]
thick = (!D.Name EQ 'PS') ? 4 : 2
; Setup colors for plot
cgLoadct,33,Clip=[10,245]
colors=['goldenrod','sky blue','blue','black']
; Setup Graphics Display
cgDisplay
; Two plots in a column.
!P.Multi=[0,1,2]
; **** First Plot
; Error estimate plot with mean, stddev, [min, max] boundaries
cgPlot, xtime, var_data, Title=title, XTitle=xtitle, YTitle=ytitle1, $
XStyle=8, Position=position1,/NoData, YRange=[0,900], $
XRange=[86.0, 88.0], YStyle=1
; Fill in the error estimates
cgColorFill, [xtime, Reverse(xtime), xtime[0]], $
[high_error, Reverse(low_error), high_error[0]], $
Color=colors[1], Position=position1
; Draw the line plot with no data
cgPlotS, xtime, var_data, linestyle=0, thick=2,Color=colors[3]
cgPlotS, xtime, var_min, linestyle=2, thick=2, Color=colors[2]
cgPlotS, xtime, var_max, linestyle=2, thick=2, Color=colors[2]
; **** Second plot
; Draw the bottom plot without a top axis
cgBarPlot, npoints, Colors=colors[0], BarCoords=xtime,Position=position2, $
YTitle=ytitle2, XTitle=xtitle, XRange=[86.0,88.0], YRange=[0,100]
; Repair some of the damage to the axes.
cgPlots, [0.15, 0.15], [0.50, 0.52], /Normal ; Fix left axis.
cgPlots, [0.90, 0.90], [0.50, 0.52], /Normal ; Fix right axis.
; Clean up.
!P.Multi = 0
END
; Display the plot in a graphics window.
Test_Plot
; Display the plot in a resizeable graphics window.
cgWindow, 'Test_Plot', WBackground='White', $
WTitle='Test Plot
; Create a PostScript file.
cgPS_Open, 'test_plot.ps'
Test_Plot
cgPS_Close
; Create a PNG file with a width of 600 pixels.
cgPS2Raster, 'test_plot.ps', /PNG, Width=600
END
; --------------------------
Thanks in advance.
|