prevent overlapping x-labels without stretching the graph too much - r

I am making a graph using ggplot however my x-axis labels are overlapping.
see both graphs here: https://imgur.com/a/D1HsVlA
I have looked online and found out that changing the width through save as image option seems to do the job however this stretches my graph a lot horizontally. Is there a way to prevent x axis labels from overlapping without tremendously stretching out my graph?

Related

VisJS Zooming Function

I have a VisJS graph plotted on top of a map. I want to zoom both in and out in unity with a button. Unfortunately the visjs graph seems to have a weird way of scaling as it seems to be very slight around 1 and much further around 0.5 and 1.5.
I tried finding the function that makes the scaling in visjs but there is nothing in the documentation. There also seems to be no one who has had this problem before.
Any Ideas where I could find a function that fits the scaling to a linear scaling map?
Or a functiont that would doubles/halfs the current graph size?

R ggplot2 use RStudio Chart Zoom settings to save Chart

Expanding the question by Jeremy K. in this question here Set ggsave() aspect ratio to the ratio that RStudio's "Zoom" button gives? specifically
I am using ggsave() to save plots from ggplot().
In R-Studio, clicking the "Zoom" button automatically resizes most of my plots to have quite aesthetic proportions, whereas when I try to manually specify the size and aspect ratios, I get plots that don't look as nice.
The answer to the original question and the answers to the similar question R: save figures in the zoomed window with command? both address screen size/resolution but nothing else. As the original question states the RStudio zoom has aesthetic proportions but using the screen width and height only sets the chart size and resolution. The titles, labels etc are all different (tiny in my case) in the saved image versus the original Rstudio zoomed image. Unfortunately using the 'inspect element' suggestion only gives the screen size and not any of the title and label sizes.
Is there a way that I can make ggsave (or any function) use the same aspect ratio or size ALL the same formats that R-Studio's "Zoom" button does?

Use mouse to manually adjust geom_text() position?

Just wondering if there is any package/functionality to manually manipulate the positioning of text from geom_text()? I've been using ggrepel::geom_repel_text() for positioning without overlap, which is good for most cases, but when I have a ton of points all clustered in a tight space it would be much easier to just move them around without having to figure out the coordinates associated with each spot. Is this possible?
In case your problem relates to deciding which points to label, here's a Shiny app which allows for manual selection of points to label in a ggplot. It relies on ggrepel to space them, so if you want manual control, Marius makes a good suggestion.
https://github.com/AliciaSchep/gglabeller

Make a Graph Webpage

I want to make the whole webpage into a graph, like a blueprint (the colour scheming). And then i want to plot a graph in the same page. So should i use some code to make the grid or should i just make an image file and make it the background.
The grid should be preferably something like this : Graph, or with the proper coloring Blueprint Graph
If code is suggested, please give an overview of how to do so.
Thank You.
This sounds like something you could do with HTML5 Canvas, although maybe that's above and beyond what you're looking for. Here's a pretty good free course that has relevant examples.
Since you're going to be plotting points on the graph, your best bet is to create an element, such as a <div>, and give it a fixed width and height. Then apply a background image of the graph paper to that element. You'll need to use absolute positioning when plotting points, so it's key that the graph stays in place and doesn't get skewed based on differing viewports.
If you wanted the entire viewport to be a graph, you'll need to reference the upper-left corner when plotting points (start at 0,0) since users' browsers will have varying widths and heights.

ggplot2 - autosize chart and axis titles

I have create some ggplot2 bar plots which print fine to screen. When I print in PDF device, however, the chart and axis titles are too large - they sometimes extend past the left and right of the x-axis. None of these charts have any opts() set aside from title/axis-title - its all the defaults. What am I missing here? Is there a way to tell ggplot to auto-size this text so that the charts look good in PDF? Can I do this without explicitly setting opts()?
The best solution I can think of is to create a function to create a theme (like theme_bw()) and give it enough parameters so that its smart about sizing. Will keep this post open for a few days to see if there are any other clever ideas

Resources