I'm using ggplot2 and ggraph to visualise graphs, but I have a problem with labels at the extremes of the x-axis. Here, labels stick out to the left and right and get clipped (see the left and right margins of the attached figure).
Is there any way to disable clipping? Alternatively, is there any way to extend the x-range based on label sizes?
Related
I am building a grid of geom_treemaps. There are 2 plots, side by side in one row. I want to have the legend (a continuous color gradient) span underneath the length of the entire window. To do this, I am extracting the legend from another geom with get_legend(plot) and drawing it in its own viewport. When I draw the legend, it shows no regard for the constraints of the viewport. I can adjust the legend.key.width parameter in the theme() of the plot I extracted the legend from, but that process is very manual. Is there a way to coerce this legend to fit (specifically lengthwise) into a viewport?
Thank you for any responses.
How to save multiple plots and keep their different actual-sizes on a same page (image below). arrangeGrob meets my requirement on keeping the actual size of each plot but it is not possible to align them left. plot_grid, ggarrange, and gtable provide horizontal aligning but these functions resize the plot.
If I have a graphic composed of several plots, say three plots arranged vertically. This is a gtable object and can be drawn to the page with:
grid::grid.newpage()
grid::grid.draw(plot)
However I see that the plot in my RStudio is 'smushed up' as in the screenshot below:
As you can see in the bottom right corner it is squashed and the titles overlap with other elements of the graphic.
If I hit zoom and view the plot it is a lot bigger:
Now I know, that if I were to export my gtable plot using pdf() or png() and such devices, I can set a width and a height, and so just make it big enough such that the plot is not squashed.
However, instead of one of those graphic devices, I would like to use export.grid, from the gridSVG package to save it to an SVG file. But if I do
gridSVG::export.grid(plot)
Then the SVG file exported looks squashed as it does in the RStudio plot window.
So my question is, how can I manipulate the dimensions of the graphic so it is drawn to SVG without it looking squashed? I draw the plot initially with grid.newpage and grid.draw, I wonder perhaps I have to specify some size of the page or drawing using grid.
Thanks,
Ben.
When making a multi-panel plot in lattice, each panel is by default bordered by a black line. I would like to be able to adjust the color and width of these panel borders. Bonus points if you can show how to add a colored border around specific panel(s).
For instance, this code makes a plot with three panels, one for each unique value of df$gears. Each panel is bordered by a black line.
library(lattice)
xyplot(mpg~hp|factor(gear), mtcars, layout=c(3,1), between=list(x=c(1))
,par.settings=list(axis.line=list(col="lightgray")))
This code almost does what I want. It changes the borders (and tick marks) of all panels to light gray. Is there a way to change the color of components independently (e.g., left and right axes)? Is there a way to address the formatting for each sub-panel independently?
Thanks,
Bryan
I'm trying to display a graph with the xAxis and yAxis grid lines overlayed on top of the plot.
I can set the zIndex of the plot, but there doesn't seem to be an option to set the zIndex of the grid.
If it's not possible, I can lower the opacity of the plot so that the grid shows through from underneath, but I'd rather not do it that way.
I can't find a way. Even setting zIndex on the series to -99 makes no difference. Have you considered using plot lines or plot bands to draw your own? These both support zIndex.
Update:
Original poster found that the highstock gridZIndex option works for highcharts.
http://api.highcharts.com/highstock#xAxis.gridZIndex