Making a base R plot larger - r

I am not sure if this is possible, but I was wondering if I could expand the parameters of a base R plot. I am aware you can change the resolution/sizing of the graphs when you go to save them, but this isn't what I want to do. I was wondering if there is a command to stretch out the x/y-axis without increasing the range. I attached a picture of the graph I produced, which I feel is quite cramped and small. Below is also my code, which I don't think is an issue but wanted to attach anyways just to be safe. I'd appreciate any help, thank you so much!
plot(O2water, -1*O2rate,xlim=c(19,21.25))
abline(v=20.1)

Related

Resize R plot in juputer notebook

I cannot somehow figure out how to resize the R graph, I am getting in my JupyterNotebook. No matter what I put in width or hight in options, it still remains this same.
The value of jobmemberid is a numeric data that I had to turn into a character. I feel like the bars are also of a different size, so it would be great to know if I can keep them constant.
Any hints how to go about it would be highly appreciated.

plot panel visualization using ggplot2 in R shiny

I am implementing a R shiny with a plot panel implemented by library(ggplot2). If there are 12 plots, the layout looks great. Please check below.
12-plot layout
However, if I increase the plot number to 70, then each plot looks being compressed (pls see below). Is that possible I can keep the size of each plot fixed? Thank you so much!
enter image description here
Is there another way to approach this? For instance, can you group your data by two categorical variables and use on for colouring and the other for facetting? In that way, you may be able to reduce the number of facets, and stick with the larger facet size, while still conveying all relevant information? 70 facet plots is a lot!
Is this more of a QC thing? For QC, I tend to break it into groups by condition as Paul was suggesting. The reason is that within a condition, things should be really similar. Outside a condition, all bets are off. When I do this for genomics data, I tend to use “pairs” customized to my liking.
What don’t you like about the 70 sample display? Simply the change in aspect ratio? IMO, these are the things I don’t like about ggplot. You can make these plots using base R and then place them on a page manually using par or layout. For that matter, you can do the same with ggplot and use ggarrange or a different manual layout function to place the plots. All wrapped in a for or apply of course.
The other things I like to do when I have a LOT of QCs to look through is create a movie. I can use the forward/back buttons and go through a lot quickly. I like the idea of having this in a dashboard, nice one!
you could also try coord_fixed(ratio= ), not sure if that will work with faceting or not
Finally, I have made a movie-like visualization for those 70 plots using the plot_ly function in R package "plotly".

How to change the scale of the plot in R

I have been trying to perform some of the raster related operations using R and whenever I am loading raster files in R in the plot window it is being displayed at a different scale which is hard to notice. I'm a little confused about how to bring it back to a standard size. As I'm new to the R language I'm not able to figure it out. Little help would be appreciated. Thanks in advance.
It was due to the default values set in par() function. By changing the "mar" parameter in the function I was able to resize it to my own convenience.enter image description here

How to decided between font size, margins and png() parameters to achieve good definition and consistent visualisation?

This is a question that has me banging my head against a wall for a while now. Much of R coding produces consistent results when used for analysis, in a sense that sometimes there are more than one ways to achieve something but your output would be something shareable and consistent. Let's say a dataframe or a datatable and so on and so forth.
However, I'm finding myself struggling to understand how can I achieve a mainstreamed process when generating plots. Font size, margin size, height, width and resolution. All those influence each other.
You change your resolution and suddenly your font size changes drastically when saving with png(). You go back and you change the dimensions and there you are with extremely small font size or with a pixeled chart looking at you.
So, because I still trust in the ggplot and png() process and believe that it must be me that messes up or doesn't do the correct steps in his workflow the question is:
What is the sweet point between all those factors that makes plotting with R easy, consistent and high-quality?
I understand that some of these factors cannot be standardised since it depends on the amount of information and how complex a chart is. But how do others ensure consistent font size against changes in resolution, height, width and plot margins?
I've came across some useful resources such as:
[https://blog.revolutionanalytics.com/2009/01/10-tips-for-making-your-r-graphics-look-their-best.html][1]
[https://support.rstudio.com/hc/en-us/articles/200488548-Problem-with-Plots-or-Graphics-Device][1]
But none really speaks to how you mainstream a visualization process in R. Still great tips though.
Any advice or ideas are honestly appreciated. Thank you.

Is there a way to replace the legend or axis without redrawing the whole plot?

Sometimes I will place a legend at a particular location on the plot, let's say topright, and then I see that it covers an important part of the plot. Is there a way I can switch it to topleft or some other place without having to run all the other commands first? Sometimes I have the same problem with the axes, I misspell a word and then I have to issue all the commands again.
I eventually place everything in an R script which means this becomes less of a problem, but sometimes I want to quickly test something in console. Please tell me I have overlooked a basic command that does this.
There is no such thing, but you're on the right track - a script is definitely the way to go. I would also recommend R Studio, a free R IDE, which gives you several displays, one for scripts, one for the console, one for your plots - it's great! It makes working with scripts as easy as interacting with the traditional R console.
As Gabriel told you, a script is the best way. However, the following link could help you:
Using Inkscape to Post-edit Labels in R Graphs

Resources