[R] histogram-like plot with two variables

jim holtman jholtman at gmail.com
Mon Sep 29 04:48:22 CEST 2008


Try:

plot(x,y,type='s')
lines(x,y, type='h')

On Sun, Sep 28, 2008 at 10:02 PM, Jörg Groß <joerg at licht-malerei.de> wrote:
> Hi,
>
> I want to plot a binomial propability distribution.
>
> I know how to generate the data;
>
>   x <- seq(from=0, to=14, by=1)
>   y <- dbinom(x, 14, 0.7, log = FALSE)
>
> but what I don't know is how to plot this within a histogram like plot.
> Because the histogram function only accepts one variable.
>
> Is there a way to get the look of "hist()" with two variables?
>
>
>
> I tried:
> plot(x,y, type="h")
>  but the bars are very thin -is there a way to define the width?
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list