Adding line to a barplot [message #93179] |
Mon, 09 May 2016 07:53  |
jecca.baker
Messages: 12 Registered: October 2014
|
Junior Member |
|
|
Hello,
I use the following lines to plot a line on top of a barchart
data1=[277.9,260.4,257.6,169.0,89.3,31.7,18.9,23.2,79.6,163. 4,207.6,255.5]
data2=[26,26,27,27,26,26,25,25,26,27,27,26]
cols=intarr(12)+80
cgbarplot,data1,yrange=[0,300],color=cols
cgaxis, yaxis=1,yrange=[20,30],/save
cgoplot,indgen(12)+0.5, data2,psym=-6
My problem is that I cannot make the points in the line centre over the middle of the bars. Does anyone know how to fix this?
Many thanks,
Jess
|
|
|
Re: Adding line to a barplot [message #93180 is a reply to message #93179] |
Mon, 09 May 2016 10:22   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
I haven't tried it but perhaps the barcoords output keyword to cgbarplot would be useful:
; barcoords: out, optional, type=float
A vector of values for the center point of the bars.
--Wayne
On Monday, May 9, 2016 at 10:53:43 AM UTC-4, Jess wrote:
> Hello,
>
> I use the following lines to plot a line on top of a barchart
>
> data1=[277.9,260.4,257.6,169.0,89.3,31.7,18.9,23.2,79.6,163. 4,207.6,255.5]
> data2=[26,26,27,27,26,26,25,25,26,27,27,26]
> cols=intarr(12)+80
> cgbarplot,data1,yrange=[0,300],color=cols
> cgaxis, yaxis=1,yrange=[20,30],/save
> cgoplot,indgen(12)+0.5, data2,psym=-6
>
> My problem is that I cannot make the points in the line centre over the middle of the bars. Does anyone know how to fix this?
>
> Many thanks,
>
> Jess
|
|
|
Re: Adding line to a barplot [message #93194 is a reply to message #93179] |
Tue, 10 May 2016 22:49   |
ZP Yin
Messages: 3 Registered: April 2016
|
Junior Member |
|
|
在 2016年5月9日星期一 UTC+8下午10:53:43,Jess写道:
> Hello,
>
> I use the following lines to plot a line on top of a barchart
>
> data1=[277.9,260.4,257.6,169.0,89.3,31.7,18.9,23.2,79.6,163. 4,207.6,255.5]
> data2=[26,26,27,27,26,26,25,25,26,27,27,26]
> cols=intarr(12)+80
> cgbarplot,data1,yrange=[0,300],color=cols
> cgaxis, yaxis=1,yrange=[20,30],/save
> cgoplot,indgen(12)+0.5, data2,psym=-6
>
you can watch the example 'Bar Plot with Error Bars' in https://www.idlcoyote.com/gallery/
for help
And as wlandsman has answersed, barcoords output keyword to cgbarplot would be useful.
> My problem is that I cannot make the points in the line centre over the middle of the bars. Does anyone know how to fix this?
>
> Many thanks,
>
> Jess
|
|
|
Re: Adding line to a barplot [message #93272 is a reply to message #93194] |
Thu, 26 May 2016 06:31  |
jecca.baker
Messages: 12 Registered: October 2014
|
Junior Member |
|
|
On Wednesday, May 11, 2016 at 6:49:42 AM UTC+1, ZP Yin wrote:
> 在 2016年5月9日星期一 UTC+8下午10:53:43,Jess写道:
>> Hello,
>>
>> I use the following lines to plot a line on top of a barchart
>>
>> data1=[277.9,260.4,257.6,169.0,89.3,31.7,18.9,23.2,79.6,163. 4,207.6,255.5]
>> data2=[26,26,27,27,26,26,25,25,26,27,27,26]
>> cols=intarr(12)+80
>> cgbarplot,data1,yrange=[0,300],color=cols
>> cgaxis, yaxis=1,yrange=[20,30],/save
>> cgoplot,indgen(12)+0.5, data2,psym=-6
>>
>
> you can watch the example 'Bar Plot with Error Bars' in https://www.idlcoyote.com/gallery/
> for help
>
> And as wlandsman has answersed, barcoords output keyword to cgbarplot would be useful.
>
>> My problem is that I cannot make the points in the line centre over the middle of the bars. Does anyone know how to fix this?
>>
>> Many thanks,
>>
>> Jess
Thanks both very much for you help - barcoords did just the trick :-)
|
|
|