I'm making a gif using Julia Plots, however, as the frames progress the grid autoscales making it seem very jittery, if anyone knows if I can simply set the exact size of the grid such that it remains stagnant that would be a great help.
scatter(planex, planey, markersize=1.2, aspect_ratio=:equal, xlims=(-2.5,2.5))
^ this is the line that plots x and y the values (planex and planey)
I tried setting the x-limits and aspect ratio expecting it to keep the frames from resizing.
What resulted is that after a large amount of frames the image stops deforming but in earlier parts it still jitters.
Have you tried also setting ylims?
Related
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.
I am trying to create a figure of a map of a continuous trait onto a phylogenetic tree using the ape and phytools packages in R for a publication. An example code of what I am trying to produce is as follows:
library("ape")
library("phytools")
orig_tree<-rtree(n=350)
plot(orig_tree)
values<-data.frame("residuals"=runif(350,min=-1,max=1),row.names=orig_tree$tip.label)
values<-setNames(values$residuals,rownames(values))
residualsignalfit<-fastAnc(orig_tree,values,vars=TRUE,CI=TRUE)
obj<-contMap(orig_tree,values,plot=FALSE)
plot(obj,type="fan",fsize=.1,lwd=0.5)
The only difference is the terminal of the branches are all the same length because they are all living taxa, but this works well enough to illustrate the problem I am having. I have a large number of taxa in this tree, and as a result I have to shrink the text down fairly small using the fsize= argument to make them legible. However, as you can see from the example code, doing so causes the ends of each species name to be obscured by the outline for the phylogenetic tree. I have tried removing the outline but it makes the heatmap of the phylogeny very hard to read. I have been unable to find any way to reduce the thickness of the outline, it seems to be automatically generated.
I also tried adding the cex command to plot(obj...), but it has no effect on the produced tree at all.
What I am trying to figure out how to do is how to position the tip labels in order to make them more legible and not covered up by the outline for the tree. I cannot simply add a space in front of each terminal using the dplyr mutate function or something like that because the position of the taxon name is not always consistent, sometimes the left side of the name is attached to the tip and other times it is the right side. I have tried not plotting the data as a fan, but this ends up creating a figure with a huge amount of dead space due to the fact I have some very deep splits within the tree (basically plotting the figure as a right-facing tree results in half of the figure being dead space because my taxa diverged in the Mesozoic but only speciated after the K-T boundary).
Instead of shrinking the text down, you can scale the tree up. You can export the plot as image with a specific width and height. Setting both to 20 should make all tip labels legible.
Something like
setEPS()
postscript("output.eps", width = 20, height = 20)
plot(obj,type="fan",lwd=0.5)
dev.off()
This saves the plot to output.eps instead of showing it in the default viewer. So it is not restricted by the screen size. You still need to fiddle around with the best values of lwd and fsize, but in my experience it is much easier, when you have a big canvas.
Edit: Sorry, the unit of width and height is inches not pixels. So rather set it to 10 or 20.
I have this problem where R will auto-adjust the size of the facets in ggplot. In the 2 attached images, clearly, the one scaled from 0-100 on the y-axis is less stretched out compared to the one scaled at 6.6-7.2. These are plotted using the same ggplot commands from maaply, so I don't know where the difference would come from. Is there any way to prevent R from performing the auto-adjusting to keep the formatting of each ggplot the same? My OCD and I thank you.
It looks like I have made a copy and paste error where I used some the the wrong variable to set the base_height in save_plot within mapply, so the scaling factor was varying across iterations.
I am running R in jupyter, but I am running across some issues with plotting. Specifically whenever I plot the returned plotting window takes up the entire screen. I tried changing the dimension of the plot in R with par(pin=c(1,1)) etc... and it shrunk the actual image of the plot, but the cell width the images is in still takes up the entire screen. I can zoom out in my browser, but then I can't see my lines of code.
Code:
x <- runif(100)
hist(x)
Any suggestions on how to fix this would be appreciated. Thanks.
P.S. I would post an image, but I just created this account and need at least 10 rep points to post images
Answer:
I was able to change the options with the code below so my plots looked a little bit more reasonable
options(repr.plot.height=3)
options(repr.plot.width=3)
Apologies if this is a very trivial question, but I have spent a few hours already on this. I have a ggplot with a facet grid which includes several factors. The problem is that the headings of the facets are not readable. There are 'too many'.
facet_grid(years.since.peace ~ type_of_termination+strategy.cm6.YP)
I know that I could change the font size of the panel headings, or split it into several different graphs.
But what I am interest in is to enlarge the plot area so that there is enough space for all headings of the panels/facets? The graph is likely to end up as a poster, so printing it in e.g. A2 would be fine.
I checked the space, scale and shrink options - but it seems they are not meant for what I am trying to do. I also tried to modify the pdf() command with its width and height options. But the graph simply becomes larger without solving the problem of the unreadable facet headings.
Maybe I am simply wrong with what I am trying to do?
you could try:
library(ggplot2)
ggsave('testplot.png', height = 11, width = 8.5)