[R] Help needed in plotting 2d histogram

Jim Lemon drjimlemon at gmail.com
Fri Dec 18 08:08:09 CET 2015


Hi Saikat,
I don't know whether this can be done with ggplot, but if you don't get
another answer, have a look at the second example for the "barp" function
in the plotrix package. This shows how to get a specified range on the
color legend using the "xrange" argument.

Jim


On Fri, Dec 18, 2015 at 2:52 PM, Saikat Dutta Chowdhury <
saikatduttachowdhury at gmail.com> wrote:

> Hello.
> I have more than one phi-psi time series data files each having 50000 time
> points.
> I am trying to create density plots (2d histograms) for each and then I
> would like to compare them. But to be able to compare one plot with the
> other I need to have similar colour densities (i.e colour gradient (which
> depends on counts) will be same for each). But I am unable to control the
> colour gradient and thus unable to compare the plots.
>
> I was using ggplot2 library. After getting the phi-psi data into R I was
> doing the following steps:
>
>
> *df <- data.frame(phi[,2],psi[,2])*
>
> *p <- ggplot(df,aes(phi[,2],psi[,2]),ymin=c(-180,180),xmin=c(-180,180))*
> *p + stat_bin2d(bins=100)*
>
> after executing these steps I am getting the density plot with the colour
> gradient legend at the left side with a certain range (say 0-200). I want
> to control this colour gradient parameter so that I can fix this range to
> 0-600 for all the plots and thus be able to compare them.
>
> Any help would be appreciated.
>
> With regards,
> --
> Saikat Dutta Chowdhury
> Research Fellow
> University of Calcutta
> India
> Mobile: 8017650842
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list