Displaying 20 results from an estimated 2000 matches similar to: "ggplot / second axis / just a notation problem"
2017 Oct 12
2
dual y-axis for ggplot
Hi,
To my knowledge, an excellent of ggplot with a second y-axis is
https://rpubs.com/MarkusLoew/226759
In this example, the author uses two colors for the two lines, but the
line shapes are the same -- both are solid. Could each line have its own
color as well as its own shape? For example, can I make the red line with
the linetype "twodash", while the blue line with the
2017 Oct 17
0
ggplot / second axis / just a notation problem
Hi John,
Why not just try both and see which one makes sense?
On Tue, Oct 17, 2017 at 12:24 PM, John <miaojpm at gmail.com> wrote:
> Hi,
>
> I have a question on ggplot2 with the second axis, but I don't think one
> needs to know ggplot2 package in order to answer this question.
>
> In this example,
> https://rpubs.com/MarkusLoew/226759
> since the
2017 Oct 12
0
dual y-axis for ggplot
Sorry let me clarify.
If I modify the line
p <- p + geom_line(aes(y = air_temp, colour = "Temperature"))
by
p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype
="Temperature"))
and
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity"))
by
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
2017 Oct 12
1
dual y-axis for ggplot
Hi John,
You can try the following:
override.linetype=c("twodash","solid")
p <- ggplot(obs, aes(x = Timestamp))
p <- p + geom_line(aes(y = air_temp, colour = "Temperature", linetype
="Temperature"))
p <- p + geom_line(aes(y = rel_hum/5, colour = "Humidity",
linetype="Humidity"))
p <- p +
2023 Nov 24
1
ggplot adjust two y-axis
Dear R-users
Is it possible to adjust two y-axis in a ggplot differently?
- First y axis (0-60)
- Second y axis (0-2500)
### Figure 1
ggplot(Fig1,aes(BFF,Wert,fill=Studien_Flaeche))+
geom_bar(stat="identity",position='dodge')+
scale_y_continuous(name="First Axis", sec.axis=sec_axis(trans=~.*50,
name="Second Axis"))+
2023 Nov 24
1
ggplot adjust two y-axis
Hi Sibylle,
For that kind of data with two different scales, I generally use two graphs
that I name gg1 and gg2 and join them using gridExtra::grid.arrange(gg1,
gg2). This way, the red part of your graph is easier to interpret.
Have a nice day,
Charles-?douard
-----Message d'origine-----
De?: R-help <r-help-bounces at r-project.org> De la part de
sibylle.stoeckli at gmx.ch
Envoy??:
2023 Nov 24
1
ggplot adjust two y-axis
Hi,
I don't know the axis mecanism well enough in ggplot but using the original
barplot function you can add an axis on the right using the axis function.
Here is an example:
test <- as.table(matrix(c(2,10,3,11), 2,2))
barplot(test, beside = TRUE, col = scales::brewer_pal(palette = 1)(2))
axis(4, at = c(0, 5, 10), labels = c(0,50,100))
-----Message d'origine-----
De?:
2023 Nov 24
1
ggplot adjust two y-axis
Dear Charles-Edouard
Thanks a lot. Yes indeed barplot sounds excellent.
Unfortunately, the scale of the smaller axis is fixed, even If I am able to
draw to axes. The idea is to expand the scale to the scale to the second
axis for comparison.
F1 <- as.table(matrix(c(50,11,6,17,16,3,1,2237,611,403,240,280,0,0), 2,7))
barplot(F1, beside = TRUE, col = c("blue", "grey"))
2023 Nov 24
1
ggplot adjust two y-axis
Hi,
Just find a scaling factor that would make the two sets of data comparable.
Here I divided the second row by 5 and did the same for the second axis.
Charles-?douard
F1 <- as.table(matrix(c(50,11,6,17,16,3,1,2237,611,403,240,280,0,0), 2,7))
barplot(F1, beside = TRUE, col = c("blue", "grey")) axis(2,
at=c(0,10,20,30,40,50,60, labels=c(0,10,20,30,40,50,60))) axis(4, at =
2017 Aug 11
2
Annotation Ticks on the axis
Hi,
Thanks for the quick answer. I looked into the link that you provided. But
I am still not able to implement a solution. Here is my attempt :
library(ggplot2)
x<-1:10
y<-x^2
df<-data.frame(x=x,y=y)
p1<-ggplot(df,aes(x,y))+geom_point()+
scale_x_log10(
breaks = scales::trans_breaks("log10", function(x) 10^x),
labels = scales::trans_format("log10",
2017 Aug 11
0
Annotation Ticks on the axis
> On Aug 11, 2017, at 3:23 AM, Vivek Sutradhara <viveksutra at gmail.com> wrote:
>
> Hi,
> Thanks for the quick answer. I looked into the link that you provided. But
> I am still not able to implement a solution. Here is my attempt :
>
> library(ggplot2)
> x<-1:10
> y<-x^2
> df<-data.frame(x=x,y=y)
> p1<-ggplot(df,aes(x,y))+geom_point()+
>
2017 Aug 11
0
Annotation Ticks on the axis
Hi
see in line
> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Vivek
> Sutradhara
> Sent: Friday, August 11, 2017 11:02 AM
> To: r-help <r-help at r-project.org>
> Subject: [R] Annotation Ticks on the axis
>
> Hi all,
>
> I would like to have help in getting annotation ticks (corresponding to the
> minor
2012 Sep 19
2
ggplot formato dígitos en ggplot2
Hola de nuevo.
Resulta que al actualizar a la versión 0.9.2 de ggplot2 , ahora en mi
eje continuo y , los valores se etiquetan en formato científico , cuando
antes era normal. Es decir, mis valores máximos están sobre 300000, pero
en el eje ahora pone 3e+05 y no he encontrado como cambiarlo.
He visto que se puede cambiar utilizando el paquete scales y utilizando
por ejemplo , siendo p un
2014 Oct 16
2
Heatmap de paro (o de otra cosa) en España
Hola Pedro.
El INE cambió los ficheros de microdatos no hace mucho, aquí dejo como
se haría ahora, (utilizando MicroDatosEs). Lo que cambia es la función
para recodificar.
http://rpubs.com/joscani/unemplrate
El 15/10/14 a las #4, Carlos Ortega escribió:
> Hola Pedro,
>
> Acabo de recordar que hace poco José Luis Cañadas (participa en esta lista)
> publicó un enlace suyo a un
2007 Dec 11
2
ggplot - Setting the y-scale in a bar plot
Dear All (probably Hadley),
I am now trying to customise some plots using a bar geom.
I do not want to use the default binning statistic, but rather
calculate the bar heigths separately. I do manage this, but for
comparison purposes I would like to have a set of plots all with the
same y-axis height. But I do not seem to find out how to fix the
scale of the y-axis in this case.
Any tips?
2017 Aug 11
2
Annotation Ticks on the axis
Hi all,
I would like to have help in getting annotation ticks (corresponding to the
minor grid) on my plot. Here is my toy example :
par(mar=c(5, 6, 5, 5) + 0.1)
x<-1:10
y<-x^2
plot(x,y,log="xy",xlab="log(x)",ylab="log(y)")
par(new=T)
2016 Mar 10
2
getParseData() for installed packages
I can't seem to reliably obtain parse data via getParseData() for
functions from installed packages. The parse data seems to be available
only for the *last* file in the package.
See [1] for a small example package with just two functions f and g in
two files a.R and b.R. See [2] for a documented test run on installed
package (Ubuntu 15.10, UTF-8 locale, R 3.2.3). Same behavior with
2017 Oct 07
2
Adjusted survival curves
For adjusted survival curves I took the sample code from here:
https://rpubs.com/daspringate/survival
and adapted for my date, but got error.
I would like to understand what is my mistake. Thanks!
#ADAPTATION FOR MY DATA
library(survival)
library(survminer)
df<-read.csv("F:/R/data/base.csv", header = TRUE, sep = ";")
head(df)
ID start stop censor sex age stage treatment
1
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
2007 Jul 14
1
scaling of different data sets in ggplot
Dear list (but probably mostly Hadley):
In ggplot, operations to modify 'guides' are accessed through grid
objects, but I did not find mention of creating new guides or possibly
removing them altogether using ggplot functions. I wonder if this is
something I need to learn grid to learn more about (which I hope to do
eventually).
Also, ggplot()+geom_object() [where 'object' can be