logo
down
shadow

Greek letters, symbols, and line breaks inside a ggplot legend label


Greek letters, symbols, and line breaks inside a ggplot legend label

By : John_G
Date : November 15 2020, 06:54 AM
help you fix your problem Baptiste's suggestion was spot on: unicode go a long way. Replace every instance of gamma above with \u03B3 and it will display as Greek. Amazing!
Printing can be done with the cairo device (ref):
code :
library(Cairo)
cairo_pdf(file = "ggplot-greek.pdf", width = 8, height = 5)
## ggplot object created here
dev.off()
"\U016B" = ū
"\U016A" = Ū
"\U00FB" = û
"\U00DB" = Û
"\U0233" = ȳ
"\U0232" = Ȳ
"\U0177" = ŷ
"\U0176" = Ŷ
"\U0113" = ē
"\U0112" = Ē
"\u00EA" = ê
"\U00CA" = Ê
"\U003BC\U2080" = μ₀
"\U003BC\U2081" = μ₁
"R\U00B2" = R²
"\u221E" = ∞
"\u2248" = ≈
"\U2260" = ≠ 
"\u03C3/\u221An" = σ/√n
myplot + labs(title  = "±")
title = expression(paste("z = (", bar(x), "-\u03BC)/(\u03C3/\u221An)", sep = ""))  
library(ggplot2)
ggplot() + labs(title = title) + theme_bw() 
\u0391  Α   Greek Capital Letter Alpha
\u0392  Β   Greek Capital Letter Beta
\u0393  Γ   Greek Capital Letter Gamma
\u0394  Δ   Greek Capital Letter Delta
\u0395  Ε   Greek Capital Letter Epsilon
\u0396  Ζ   Greek Capital Letter Zeta
\u0397  Η   Greek Capital Letter Eta
\u0398  Θ   Greek Capital Letter Theta
\u0399  Ι   Greek Capital Letter Iota
\u039A  Κ   Greek Capital Letter Kappa
\u039B  Λ   Greek Capital Letter Lambda
\u039C  Μ   Greek Capital Letter Mu
\u039D  Ν   Greek Capital Letter Nu
\u039E  Ξ   Greek Capital Letter Xi
\u039F  Ο   Greek Capital Letter Omicron
\u03A0  Π   Greek Capital Letter Pi
\u03A1  Ρ   Greek Capital Letter Rho
\u03A3  Σ   Greek Capital Letter Sigma
\u03A4  Τ   Greek Capital Letter Tau
\u03A5  Υ   Greek Capital Letter Upsilon
\u03A6  Φ   Greek Capital Letter Phi
\u03A7  Χ   Greek Capital Letter Chi
\u03A8  Ψ   Greek Capital Letter Psi
\u03A9  Ω   Greek Capital Letter Omega
\u03B1  α   Greek Small Letter alpha
\u03B2  β   Greek Small Letter beta
\u03B3  γ   Greek Small Letter gamma
\u03B4  δ   Greek Small Letter delta
\u03B5  ε   Greek Small Letter epsilon
\u03B6  ζ   Greek Small Letter zeta
\u03B7  η   Greek Small Letter eta
\u03B8  θ   Greek Small Letter theta
\u03B9  ι   Greek Small Letter iota
\u03BA  κ   Greek Small Letter kappa
\u03BB  λ   Greek Small Letter lambda
\u03BC  μ   Greek Small Letter mu
\u03BD  ν   Greek Small Letter nu
\u03BE  ξ   Greek Small Letter xi
\u03BF  ο   Greek Small Letter omicron
\u03C0  π   Greek Small Letter pi
\u03C1  ρ   Greek Small Letter rho
\u03C2  ς   Greek Small Letter final sigma
\u03C3  σ   Greek Small Letter sigma
\u03C4  τ   Greek Small Letter tau
\u03C5  υ   Greek Small Letter upsilon
\u03C6  φ   Greek Small Letter phi
\u03C7  χ   Greek Small Letter chi
\u03C8  ψ   Greek Small Letter psi
\u03C9  ω   Greek Small Letter omega
# http://www.fileformat.info/info/unicode/category/Sc/list.htm
Character   Name    Browser     Image
\u0024  DOLLAR SIGN     $
\u00A2  CENT SIGN   ¢
\u00A3  POUND SIGN  £
\u00A4  CURRENCY SIGN   ¤
\u00A5  YEN SIGN    ¥
\u058F  ARMENIAN DRAM SIGN
\u060B  AFGHANI SIGN    ؋
\u09F2  BENGALI RUPEE MARK  ৲
\u09F3  BENGALI RUPEE SIGN  ৳
\u09FB  BENGALI GANDA MARK
\u0AF1  GUJARATI RUPEE SIGN     ૱
\u0BF9  TAMIL RUPEE SIGN    ௹
\u0E3F  THAI CURRENCY SYMBOL BAHT   ฿
\u17DB  KHMER CURRENCY SYMBOL RIEL  ៛
\u20A0  EURO-CURRENCY SIGN  ₠
\u20A1  COLON SIGN  ₡
\u20A2  CRUZEIRO SIGN   ₢
\u20A3  FRENCH FRANC SIGN   ₣
\u20A4  LIRA SIGN   ₤
\u20A5  MILL SIGN   ₥
\u20A6  NAIRA SIGN  ₦
\u20A7  PESETA SIGN     ₧
\u20A8  RUPEE SIGN  ₨
\u20A9  WON SIGN    ₩
\u20AA  NEW SHEQEL SIGN     ₪
\u20AB  DONG SIGN   ₫
\u20AC  EURO SIGN   €
\u20AD  KIP SIGN    ₭
\u20AE  TUGRIK SIGN     ₮
\u20AF  DRACHMA SIGN    ₯
\u20B0  GERMAN PENNY SIGN   ₰
\u20B1  PESO SIGN   ₱
\u20B2  GUARANI SIGN    ₲
\u20B3  AUSTRAL SIGN    ₳
\u20B4  HRYVNIA SIGN    ₴
\u20B5  CEDI SIGN   ₵
\u20B6  LIVRE TOURNOIS SIGN     ₶
\u20B7  SPESMILO SIGN   ₷
\u20B8  TENGE SIGN  ₸
\u20B9  INDIAN RUPEE SIGN   ₹
\u20BA  TURKISH LIRA SIGN   ₺
\u20BB  NORDIC MARK SIGN    ₻
\u20BC  MANAT SIGN  ₼
\u20BD  RUBLE SIGN  ₽
\uA838  NORTH INDIC RUPEE MARK
\uFDFC  RIAL SIGN   ﷼
\uFE69  SMALL DOLLAR SIGN   ﹩
\uFF04  FULLWIDTH DOLLAR SIGN   $
\uFFE0  FULLWIDTH CENT SIGN     ¢
\uFFE1  FULLWIDTH POUND SIGN    £
\uFFE5  FULLWIDTH YEN SIGN  ¥
\uFFE6  FULLWIDTH WON SIGN  


Share : facebook icon twitter icon
Greek letters in ggplot annotate

Greek letters in ggplot annotate


By : user2168676
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , I want to add greek letters into text in ggplot. Here is what I want to do: , Your link states that in annotate you should use parse = TRUE. So
code :
ggplot(df, aes(x = x, y = y)) + geom_point() +
  annotate("text", x = xIntercept, y = yIntercept, label = temp, color = "blue", parse = TRUE)
temp <- paste("theta == ", xIntercept)
Greek letters in legend in R

Greek letters in legend in R


By : Tamil
Date : March 29 2020, 07:55 AM
To fix this issue The better, looped answer comes from here and user20650.
Solution with sapply
code :
curve(sin(x), from = 1, to = 3, lty = 1, ylim = c(-1, 1))
curve(sin(2 * x), add = TRUE, lty = 2)    
curve(sin(3 * x), add = TRUE, lty = 3)
legend("topright",
       legend = sapply(1:3, function(x) as.expression(substitute(alpha == B,
                                                                 list(B = as.name(x))))),
       lty = 1:3)
curve(sin(x), from = 1, to = 3, lty = 1, ylim = c(-1, 1))
curve(sin(2 * x), add = TRUE, lty = 2)    
curve(sin(3 * x), add = TRUE, lty = 3)
legend("topright", legend = c(expression(paste(alpha, " = ", 1)),
                              expression(paste(alpha, " = ", 2)),
                              expression(paste(alpha, " = ", 3))), lty = 1:3)
Multiple greek letters in one legend line

Multiple greek letters in one legend line


By : Primael Bruant
Date : March 29 2020, 07:55 AM
should help you out I have the following piece of R code: , We can use bquote for this
code :
matplot(x,mat,type="l",col=1:3,lty=1,xlab="x",ylab="mat",main="Legend Practice")
legend("bottomright",col=1:3,lty=1, legend=as.expression(c(
        bquote(alpha~'='~.(a[1])~', '~beta~'='~.(b[1])~', '~gamma~'='~.(g[1])),
        bquote(alpha~'='~.(a[2])~', '~beta~'='~.(b[2])~', '~gamma~'='~.(g[2])),
        bquote(alpha~'='~.(a[3])~', '~beta~'='~.(b[3])~', '~gamma~'='~.(g[3])) )))
legend("bottomright",col=1:3,lty=1, legend = as.expression(sapply(1:length(a),
  function(i) bquote(alpha~'='~.(a[i])~', '~beta~'='~.(b[i])~', '~gamma~'='~.(g[i])))))
legend("bottomright",col=1:3,lty=1, legend = as.expression(mapply(function(x,y, z) 
       bquote(alpha~'='~.(x)~', '~beta~'='~.(y)~', '~gamma~'='~.(z)),
               a, b, g)))
Label affects legend symbols in ggplot

Label affects legend symbols in ggplot


By : Eric
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Add show.legend = FALSE within your geom_label_repel call. The a's seem to be the standard legend for the labels, which overrides the geom_point that uses the same colours.
Modify facets label names in ggplot with greek letters and superscripts

Modify facets label names in ggplot with greek letters and superscripts


By : MeekChen
Date : March 29 2020, 07:55 AM
To fix this issue One way is to use label_parsed as a labeller. But to do that the labels of the faceting factor need to be changed to what is to be displayed.
I will use the built-in dataset iris as an example.
code :
library(ggplot2)

iris$Species <- factor(iris$Species, 
                       labels = c(bquote(delta^2*H),
                                  bquote(delta^13*C),
                                  bquote(delta^15*N)))

p <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Width)) +
  geom_point()

p + facet_grid(~ Species,
               scale = "free_x",
               labeller = label_parsed
               )
Related Posts Related Posts :
  • Selecting unique rows using sqldf package in R
  • why am i getting "month.observed" object not found even though it has been defined in R?
  • Using German characters (ü, ö, ä, etc.) in text analysis (R)
  • R JAGS: Dimension mismatch
  • R - How to create a function that accepts a code block as parameter?
  • How do I manually set geom_bar fill color in ggplot
  • How can I get my points to connect in a plot and show a trend with NA values in data?
  • Read SPecific lines of a CSV file in R-language
  • ggplot stacked bar plot from 2 separate data frames
  • auto.arima not parallelizing
  • Histogram of binned data frame in R
  • R rewriting stringmanipulations implemented in loop to the R-way
  • get first entries in rows of list?
  • Conditionally removing rows from a matrix in R
  • Using a loop to find P(-1.5<Y<1.5) for a range of sample sizes
  • R-Count and list the maximum count row by row
  • Include Iverson Bracket in R documentation
  • update a data frame and environment in R
  • How to write dynamic cumulative multiple in R
  • format time using as.POSIX in R
  • Change the class of multiple columns
  • Remove period and spaces within column headings nested in a list of data frames
  • R: error message --- package error: "functionName" not resolved from current namespace
  • labels with geom_text ggplot2
  • Passing mongodb ISODate in R
  • Importing "csv" file with multiple-character separator to R?
  • Change row names of a table obtained from a lm regression using xtable function
  • R language iterate over R object
  • How do you delete the header in a dataframe?
  • Re coding in R using complicated statement
  • accumulating functions and closures in R
  • How do you combine two columns into a new column in a dataframe made of two or more different csv files?
  • Twitter authentication fails
  • Summing Values of One Vector Conditional on Values of Another Vector
  • draw cube into 3D scatterplot in RGL
  • lme4 translate formula to code in 3-level model
  • How to draw single axis plot in R
  • Combine geom_tile() and facet_grid/facet_wrap and remove space between tiles (ggplot2)
  • Use snpStats with R version 3.0.1
  • Makefile gives strange error while compiling markdown file into .docx file
  • How to determine whether a points lies in an ellipse
  • Summarize data already grouped in r
  • Is the bigvis package for R not available for R version 3.0.1?
  • Operator overloading in R reference classes
  • How to enable user to switch between ggplot2 and gVis graphs in R Shiny?
  • Is there an easy way to separate categorical vs continuous variables into two dataset in R
  • Correct previous year by id within R
  • Installation of rdyncall package for R
  • ggplot2 plot that evaluates the percentage and mean of a third variable at intersecting points
  • Error Handling with Lapply
  • data.table - split multiple columns
  • How to compute the overall mean for several files in R?
  • R: Graph Plotting: Subscripts in the legend like LaTeX
  • Restructuring data in R
  • Distance of pointsfrom cluster centers after K means clustering
  • R incorrect value of date function
  • Package "Imports" not loading in R development package
  • r - run a user defined function several times by taking column elements as parameters
  • Create input$selection to subset data AND radiobuttons to choose plot type in Shiny
  • Generate crosstabulations from dataframe of categorical variables in survey
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org