degree symbol for labels in R is messed up - r

I just upgraded to Ubuntu 20.04. When I use ggplot2 to plot some geographical data, I discover that the degree symbol in the axis labels is messed up (I attached a snip). Does anyone have a solution for that? The same thing occurs if I use a different plotting library (e.g.lattice). I can provide some reproducible code as well although this is not exactly an error to reproduce..
Thanks!

Related

How to Change X-Axis Label in ChromoMap?

I am new to R and I have been using chromoMap library in R to visualize annotation plots and visualizing the feature-associated data. It's a great library and produces great charts. However, I was not able to find any option for changing the x-axis label from length (bp) to anything else. Because of this, I am not able to use any of the produced charts. It sounds like a small issue, but it totally affects the usability of this great package. I followed this tutorial link and produced the below chart. In my chart and all the samples, the x-axis label is fixed and this is my problem and I am looking for a way to just change it.
library(chromoMap)
chr_file_1 = "chr_file_without_centromere.txt"
anno_file_1 = "annotation_pos.txt"
chromoMap(chr_file_1,anno_file_1)
I am wondering if anybody has the same experience ?? This package produces output as a htmlwidget object and therefore I could not change the x-axis lable. Is there any way to modify a htmlwidget object? or Any way to change this bp to something else??

R plot symbols on axis not shown correctly

Hi guys,
I have set up a new conda R-environment (on my ubuntu 20.04) and oddly, the output of the base plot function does not show symbols on the axes or axis labels but little squares with numbers instead (see attached picture).
When I use the plot function in an R-Markdown code chunk and export it as PDF, the plot is displayed correctly. However, in RStudio or when exporting the Rmd to html, the symbols appear like in the picture.
I realize this could have to do with the encoding, but don't know how to solve it. Has anyone encountered this problem before or can give me advice how to troubleshoot it?
Many thanks in advance!
Simply adding the package r-cairodevice to my R environment solved the problem.

Labels cannot be placed in second boxplots in R?

If you run the following simple code, you will notice that although in the first boxplot there are labels, this is not the case with the second boxplot where there are no labels. How to fix this? Is it an internal R bug?
I have tried to store boxplots in a working directory just in case this is an R studio graphics problem, but still... the same issue arised even then so this is not an Rstudio problem.
df=data.frame("A"=rnorm(10),"B"=rnorm(10),"C"=rnorm(10),"D"=rnorm(10))
for (i in 1:2){
boxplot(df[,1:2],xaxt='n')
axis(1,at=c(1,2))
boxplot(df[,3:4],xaxt='n')
axis(1,at=c(3,4))}

Plot 3D graphs in R-studio

Sorry for the question, but I have a variable that I would like to plot like this:
I am a newby on R, so I am having some difficulties. I appreciate any kind of help.
Thanks!
Since you're looking to plot what appears to be a 3d surface, I'd suggest starting with the persp function, from the graphics package. This blog post (http://www.r-bloggers.com/3d-plots-in-r/) gives a good treatment of several options for 3D plotting:
the generic function persp() in the base graphics package draws perspective plots of a surface over the x–y plane. Typing demo(persp) at the console will give you an idea of what this function can do.
And running demo(persp) gives you a number of examples, including this one:
There are also some more suggestions for going further:
The plot3D package from Karline Soetaert builds on on persp()to provide functions for both 2D and 3D plotting. [...] Load the package and type the following commands at the console: example(persp3D), example(surf3D) and example(scatter3D) to see examples of 3D surface and scatter plots.
As a side note, #rawr's comment is spot on - I found all this in less than a minute, using two google searches - one of which was the title of your post. I'm putting this answer up anyway, since StackOverflow posts frequently become the top google result for many topics. But the best advice I can give you going forward is that R is one of the most aggressively well-documented languages out there, both in terms of formal and informal documentation, and you can find a lot just by googling what you want to do.

Quality differences of graphics produces by PC and Mac in R

Not sure if this is the appropriate place to ask this question, so please feel free to delete it...
I've been preparing a little introduction to course lately, and in the section about saving plots I noticed something odd. When I created a figure on my work PC, it looked the way it should. But when I ran the exact same code again on my Mac at home, the image looked somewhat blurred. I tried this for the png, tiff, and jpeg formats, the result is the same, the plot looks nicer when produced on a PC. I include two graphs below so you can see for yourself. (The first the the PC plot, the second the Mac plot). Although the PC produces the better quality, the figure produced by the Mac is larger (19 vs 8 KB). Below is another image, where both figures are magnified (Mac left, PC right). While the PC draws a crisp line, the Mac produces some kind of a shading around the lines. Can anyone explain why this is the case and how I can produce better quality plots on the Mac? I played around with the options, in particular the type argument, but couldn't neither find a solution, nor find help on the internet.
Here is the code to generate the plot:
set.seed(2)
BMI<-rnorm(n=1000, m=24.2, sd=2.2)
png(file="fig3_m2.png", width=700, height=700, res=120)
par(mgp=c(1.7,.6,0), mar=c(3,3,2,2), yaxs="i")
x <- hist(BMI, freq=F, main="Distribution of BMI",
xlab="Body Mass Index", col="lightgreen",
ylim=c(0,.2),
breaks=seq(min(BMI), max(BMI), length=18))
box()
dev.off()

Resources