Displaying 20 results from an estimated 5000 matches similar to: "ggplot2: expression() in legend labels?"
2012 Apr 20
1
ggplot2: Legend title
I'm designing a set of plots intended for a general audience; here's the code for one of them, using the latest version of ggplot:
plot.enr.all <-
ggplot(data=df1, aes(x=HS_GRAD_YEAR, y=Percentage, group=Enrolled_by,
color=Enrolled_by, shape=Enrolled_by, fill=Enrolled_by)) +
geom_line() + geom_point(size=3.5) +
scale_y_continuous(breaks=seq(0, 100, 10),
2008 Jul 03
1
ggplot2 legend for vertical lines
Dear all,
The following example code produces a graph with ggplot2, to which I
add several vertical lines of arbitrary colors. I am not satisfied
with the legend: it automatically adds some vertical lines which I'd
rather not see (they confuse the reader rather than add information
in this case).
> library(ggplot2)
> dfr <- data.frame(values = sin(1:50/10),
> fact =
2012 Apr 16
1
ggplot2: scale_shape_manual
Hi,
I was trying to replicate one of the graphs given on the ggplot2 website. I
have given a sample code below. I would like to combine the legends, since
each color is uniquely mapped to a shape.
###
library(ggplot2)
leaves <- letters[1:8]
mat <- matrix(sample(1:1000,32),nrow=16,ncol=2)
colnames(mat) <- paste('t',1:2,sep='')
df <-
2011 Dec 23
1
ggplot2: behaviour with empty datasets
For example, prepare like this
> df.0 <- data.frame(x = 0, y = 0, note = "1")
> df.1 <- subset(df.0, note == "1")
> df.2 <- subset(df.0, note == "2")
Then a call to
> ggplot() + aes(x = x, y = y) +
> geom_point(data = df.1) + geom_point(data = df.2)
produces the error
> Error in eval(expr, envir, enclos) : object 'x' not found
2013 Jan 23
1
italic font for legend text when using expression function for symbols
Hello,
I'm trying to add a symbol (Delta) to plot legend with text using
"expression(paste())" but this disables the text.font that allows to use
bold or italic text.
as follows:
x=c(1:10)
y=c(1:10)
plot(x,y)
legend(1,10,legend=c("A","B","C",expression(paste(Delta, D))),
pch=c(24,18,17,16),cex=2,text.font=3,bty="n")
Any suggestion to
2023 Oct 30
1
Missing shapes in legend with scale_shape_manual
Hello,
I'm trying to plot a graph of blood glucose versus date. I also record
conditions, such as missing the previous night's medications, and
missing exercise on the previous day. My data looks like:
> b2[68:74,]
# A tibble: 7 ? 5
Date Time bg missed_meds no_exercise
<date> <time> <dbl> <lgl> <lgl>
1 2023-10-17 08:50
2008 Oct 14
1
ggplot2 plot with symbols and then add line
r <-(structure(list(TSS = c(2.8, 8.4, 11, 1.3, 4.2, 2, 3.4, 14, 8.2,
3.1, 1.4, 0.9, 0.5, 6.1, 9.2, 0.6, 1, 11, 2.4, 1.2, 1.3, 1.3,
0, 1.8, 8, 11, 11, 8.5, 8.5, 1.8, 13, 4.4, 1.4, 2.1, 0.5, 25,
25, 9.3, 6.1, 1.6, 1.5, 19, 19, 24, 9.6, 1.8, 1.4, 1), GPP = c(1.213695235,
3.817313822, 1.267930498, 10.45692825, 3.268295623, 3.505286001,
4.468225245, 0.915653726, 1.635617261, 3.726133898,
2011 Aug 24
1
Scatter plots, linear regression in ggplot2
Hi,
Based on some modification that I did to the R Cookbook Graphs Scatterplots
code, link:http://wiki.stdout.org/rcookbook/Graphs/Scatterplots%20(ggplot2)
I have some questions and I will appreciate a help:
- How do I change the legend title?
- How can I change the for each linear regression its color and linetype?
- How can I add for both the linear regression lines their equations and
Rseq
2012 Jun 08
2
changing font to italic for one entry in legend()
Hello,
I need to change the font for one of the items (C. elegans) in my
legend to italic. Can someone suggest how to accomplish this?
legend('bottomright', bty='n', c('C. elegans range', 'Study area'),
cex=0.8, fill=c('light gray', 'white'), border=c('black','black'))
I tried using lab.font=c(1,3) but R ignored and did not write
2007 Feb 14
1
legend font
Hi,
I'd like to make the text in my legends italic, but I can't figure out
how to do so. font=3 doesn't work. Googling brings up the possibility
of expression(italic()), which produces italics, but I can't get this
to work with my label data, which is a vector of strings:
legend(locator(1), legend = levels(factor(label.vector)),
col = plotting.colours, pch =plotsym.bw,
2010 Nov 26
1
How to use expression(italic()) in a "vectorized" way (within a function)?
Dear expeRts,
I would like to use expression() for creating labels in a splom, as shown in the
first minimal example below. Is there any way I can simplify having to write
"expression(italic(...))" several times?
The second example is what I tried so far, but I can't manage to get italic() to
work. Moreover, it still seems bulky...
Cheers,
Marius
## minimal example (working but
2023 Oct 31
0
Missing shapes in legend with scale_shape_manual
I believe the missing shapes are because you had set alpha=0 for the last geom point.
I expect there are better ways, but one way to handle it would be to avoid the filtering, adding columns with med and exercise status, like the following:
# setup with data provided
Date <- c('2023-10-17', '2023-10-16', '2023-10-15', '2023-10-14',
2011 Dec 01
2
legend, "lheight", and alignment
Hello,
A bit of fairly simple code, yet I don't seem to be able to manipulate it
quite as much as I would like:
1) It would be nice if the objects appearing in the legend were aligned,
and by aligned I mean the boxes are centered over the lines. Do I need to
adjust the use of "NA" in the code below to accomplish this? Here's how it
appears on my machine:
2023 Oct 31
0
Missing shapes in legend with scale_shape_manual
Tim, thanks, it helps very much. It works like a charm.
Wow, there's so much I don't understand about ggplot2 functions,
especially the aes() function. I just discovered the ggplot2-book.org
site, and I hope to read it slowly and carefully over the next couple
of weeks.
Thanks again, Tim, for all your help.
-Kevin
On Tue, 2023-10-31 at 12:35 +0000, Howard, Tim G (DEC) wrote:
> I
2017 Jun 30
0
Multiple "scale_color_manual" statements in one plot (ggplot2, flexible legend challenge)
Dear list,
I am facing an unusual situation where I need to create two sets of legends
based on the color mapping. Can't get exactly what I want and really
appreciate any advice from ggplot experts.
Let's say I have the first dataset "df1" that draws some points and based
on which a "loess" line with confidence interval is added. Then the second
dataset
2013 Apr 01
3
expression
Hi all,
I´m using
titt<- expression(paste("R con ventanas de 200 ", italic(datos)))
And it works properly on a plot(...,main=titt,..)
But if I want to add an improvement to avoid typing n on the plot so that
n<-200
titt<- expression(paste("R con ventanas de ",n, italic(datos)))
It doesn´t recognize that n is a "variable" and adds "n" letter
2011 Sep 07
2
ggplot2-Issue placing error bars behind data points
Hi all,
This seems like a basic problem, but no amount of playing with the code has
solved it. I have a time-series data set like that shown below (only longer)
and am seeking to plot the data with filled, circular points and error bars.
I would like the error bars to be behind the points otherwise they tend to
obscure the points (especially when I have a lot of points in the actual
data set).
2004 Oct 16
1
problem with axis labels
Dear R users,
Below are some R commands which produce a y-axis label that is not wholly
in the viewing area of the eps file (or the x11 window).
I have tried experimenting with the postscript bounding box, and using
such R commands as over(phantom(0),...) but I make the whole y-label
visible.
Does anyone have any suggestions for how I may fix this. (Please CC
mailing list email to p.stansell
2008 Feb 16
1
How to use a reserved word in italics in an expression
Dear R-helpers,
> label2 <- expression(paste(italic(attraction function:), 'slope'))
Error: unexpected 'function' in "label2 <-
expression(paste(italic(attraction function"
How do I tell R that in this case I don't want 'function' to be
treated as a reserved word but as a string in italics?
_____________________________
Professor Michael Kubovy
2004 Mar 15
1
Correct Computer Modern font in postscript(..) output
Hi,
I'm trying to get the correct font used when generating italic text in an R
grahic. I have a set of labels that print correctly except it seems the
italic text is justr a slanted version of the TeX computer modern normal
font... I'm using R v1.8.1 on Windows XP, and I get the same result if I
build the pdf using Adobe Acrobat or using MikTeX
The labels: