Displaying 20 results from an estimated 6000 matches similar to: "Switching X-axis and Y-axis for histogram"
2010 Jun 30
2
ggplot qplot bar removing bars when truncating scale
I'm having problems with this example, it is posted with reproduceable code
below, both with the normal 0-6 scale and the desired 3-6 scale (with bars
removed). How can I get the graph to have the desired 3-6 scale without
removing the bars. Thanks!
#Data
2011 Jun 07
1
ggplot2 Histogram with density curve
I am learning ggplot2 commands and I have figured out how to create
histograms and density curves but I am not sure how to add a density curve
on top of a histogram.
Here are the two graphs that I created.
## Histogram
t<-rnorm(500)
w<-qplot(t, main="Normal Random Sample", fill=I("blue"), colour=I("black"),
geom="histogram")
w
##Density Curve
2009 Mar 02
3
ways to put multiple graphs on single page (using ggplot2)
Hi, Here are three plots:
library(ggplot2)
data(diamonds)
randind <- sample(nrow(diamonds),1000,replace=FALSE)
dsmall <- diamonds[randind,]
qplot(carat, data=dsmall, geom="histogram",binwidth=1)
qplot(carat, data=dsmall, geom="histogram",binwidth=.1)
qplot(carat, data=dsmall, geom="histogram",binwidth=.01)
What are ways to put these three plots on a single
2010 Nov 30
2
ggplot2 histograms
Hi
With ggplot2 I can very easily create beautiful histograms but I would like to put two histograms on the same plot. The histograms may be over-lapping.
When they are overlapping the bars are shown on top of each other (so that the overall height is the sum of the two). Is there any way to get them to display overlapping (with smaller value in front, larger value behind) so that the overall
2010 Aug 11
2
help to polish plot in ggplot2
Hi,
I wanted to generate a plot which is almost like the plot generated by the
following codes.
category <- paste("Geographical Category", 1:10)
grp1 <- rnorm(10, mean=10, sd=10)
grp2 <- rnorm(10, mean=20, sd=10)
grp3 <- rnorm(10, mean=15, sd=10)
grp4 <- rnorm(10, mean=12, sd=10)
mydat <- data.frame(category,grp1,grp2,grp3,grp4)
dat.m <- melt(mydat)
p <-
2008 May 19
2
Histograms without bars
Hello
I'd like to plot a histogram of some data composed of real numbers. The
bin width I'm using is ~ 0.01, which results in high values in the y
axis, so that the area under each bar corresponds to the probability of
the data in that range.
Is is possible to plot points whose y coordinate correspond to that
probability, instead of plotting the histogram bars? In other words,
instead of
2011 Dec 23
1
simple ggplot2 question
Hello,
I am trying to make a plot using the code below. The plot is divided into two parts, using facet_grid. I would like the vertical axis (labelled 'place') to be different for each location (=part). So in the upper part, only places 'n' through 'z' are shown, while in the lower part, only places 'a' through 'm' are shown. I thought 'free_y'
2010 Jun 28
2
Stacked Histogram, multiple lines for dates of news stories?
Dear colleagues,
I have extracted the dates of several news stories from a newspaper
data base to chart coverage trends of an issue over time. They are in
a data frame that looks just like one generated by the reproducible
code below.
I can already generate a histogram of the dates with various intervals
(months, quarters, weeks years) using hist.Date. However, there are
two other
2008 Jan 15
4
Overlay plots from different data sets using the Lattice package
#After spending the entire day working on this question, I have
decided to reach out for support:
#I am trying to overlay a densityplot from one data set over a
histogram of another, if I were to plot the two individually, they
would look like:
# data frame construction
data.frame.A <- data.frame(rnorm(12*8), c(rep("one", 4), rep("two",
4), rep("three", 4)),
2008 Feb 26
4
"Raw" histogram plots
Hello
I need to plot a histogram, but insted of using bars, I'd like to plot
the data points. I've been doing it like this so far:
h <- hist(x, plot = F)
plot(y = x$counts / sum(x$counts),
x = x$breaks[2:length(x$breaks)],
type = "p", log = "xy")
Sometimes I want to have a look at the "raw" data (avoiding any kind of
binning). When x
2011 Jun 21
2
qplot/ggplot2 Questions
I took some data from an online poll about which R GUI people used most and I
am messing around with it to learn how to use qplot. Specifically I am
making a horizontal bar graph and I have two questions.
1. The categories are ordered in rather strange way at least to me. It is
not alphabetical or ascending/descending order of votes cast so i had to
manually state the order I wanted which is
2009 Jan 03
2
R Stacked Histogram
I've seen this asked, but never fully answered.
Is it possible to plot stacked histograms in R?
I have four data sets that I would like to show combined vertically in histogram format.
Is this possible?
Thank you for any feedback you can provide.
P.S. I know I can show the four sets side by side, but I want to combine them, but still uniquely identify each. Thanks again.
2009 Jul 13
1
Strange error in qplot
Hi all, whenever I try to plot a histogram using qplot() function of
"ggplot2" library, I get error like this :
> qplot(rnorm(1000), geom="histogram", binwidth=0.2, main = "", xlab="",
> ylab="")
Error in scale[[1]] : subscript out of bounds
However if I remove ylab="" argument, then it is working fine. Am I missing
something?
2009 Jul 21
1
legend title in qplot
Hi,
I've used the following command in qplot
qplot(a$V1,geom="histogram",binwidth=0.15,fill =
factor(a$V2),ylab="Frequency",xlab="Rate");
but the title in the legend shows up as factor(a$V2)...how can i change
this?
--
Rajesh.J
[[alternative HTML version deleted]]
2011 Jul 25
4
ggplot question: changing the label for the Y axis on a histogram
Some help with how to re-label the vertical axis in a histogram would be appreciated.
qplot(off.sc,weight=rel.freq,binwidth=.29,main="test Figure"+ylab("New from inside"))+ylab("New from outside")+
xlab("off.sc\nAggregated frequency plots for 17 equal intervals.")
The code
2010 May 21
2
multiple qplot histograms in one plot
Hi,
I wish to plot multiple histograms(representing different data so different
range along xaxis but y axis is the same) horizontally in ggplot2. I'd like
it to look like facets. Is this possible?
--
Rajesh.J
[[alternative HTML version deleted]]
2008 Oct 08
2
Histogram colours in lattice.
I am trying to do a histogram lattice plot and I would like the
histogram to be filled with a different colour in each panel.
Note: I want every bar in each histogram to be the same colour,
but that there should be different colours *between* histograms.
Can't seem to get this to work. I thought that something like
the following would be a goer:
set.seed(42)
X <- rnorm(200)
A <-
2009 Oct 21
1
ggplot2: Histogram with negative values on x-axis doesn't work
I have a dataset that contains numbers between -10 and 0. E.g. x =
c(-9.23, -9.56, -1.40, ...)
If I no do a
> qplot(x, geom="histogram")
I get the error:
Error: position_stack requires non-overlapping x intervals
Strangely, the following both work:
> qplot(x * -1, geom="histogram")
> qplot(x+100, geom="histogram")
Has anyone else encountered this? Is this a
2008 Mar 04
1
qplot (ggplot2) faceting histogram with missing values
Hi,
I've run into a difficulty with qplot function (in the ggplot2
package). I can facet histograms even when the faceting variable
contains missing values, but only so long as the faceting variable is
not a factor.
Example:
y1 <- rnorm(10)
x1 <- c(rep(1,5), rep(2,4), NA)
x2 <- factor(c(rep(1,5), rep(2,4), NA))
library(ggplot2)
qplot(y1, geom = "histogram", facets =
2010 Jun 18
1
ggplot2 boxplot: horizontal, univariate
In ggplot2, I would like to make a boxplot that has the following properties:
(1) Contrary to default, the meaningful axis should be the horizontal axis.
Lattice does this, for instance, by
library(lattice);bwplot(~mtcars$mpg)
(2) It is *univariate*, i.e., of a single vector, say mtcars$mpg. I do not wish to make separate plots for the different values of mtcars$cyl.
(3) Nothing on the