Plot legend text doesn't fit - r

I have problem with size of my legend. The values in this legend are very small like 2e-18 (an example below) and they take up a lot of space. What can I do in this situation?

You can play with the keywidth property, to make the legend take up more space, or set a smaller font via the label.theme setting (see the online help).

Related

How to make sure the font stays the same when using ggsave

I'm trying to add multiple plots from ggplot into my Latex report. Most plots have different dimensions, as some need to be rectangle shaped, where as some need to be square shaped. To shape the plots, I've been changing the height and width parameters in ggsave. However, this also changes the font sizes. How do I have consistent font sizes for all my plots, and also be able to change the width and height of each plot separately?
I've already specified the font size in the plot using theme(text = element_text(size=5)), but it doesn't seem to actually stay consistent between the plots.

Autosizing Text Marks in Vega

I'm currently developing my own Metrics in Vega. Here is an example...
I am just using text marks, here is the source code for a very similar example to mine. In the example height and width are specified. However, I'm looking for the text to be autosized - that is, height and width are determined from the space the marks take up. The usual global setting to do this would be, autosize: pad or autosize: fit but these don't seem to correctly fit text marks on their own.
I'm reaching out to anyone who knows how to do this. Since I am using these in a Kibana dashboard, the autofitting would allow us to scale these metrics to any size we'd like, independent of any amount of text.
Many thanks.
To answer my own question,
I defined a 100x100 grid using scales and axes in Vega. And then plotted my words to fit inside this grid - since you can specify the x,y positions of the words.
After this the autofit applied correctly. I made sure to scale the fontsize (which is height of text in pixels) to the height of the panel (external signal).
Finally I had to hide the axes. So inside the axes I added this labels: false, domain: false. With a few extra additions this was my result. This is totally resizable within Kibana.

Is there a way to make a ggplot legend resize to the width and length of the viewport it is in?

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 change fa-icon size in flexdashboard value box?

Is it possible to change the size of the fa-icons in a a flexdashboard? The caption text overlaps with the icon and is even more of an issue when a numeric value is of the order 10^4 or greater.
It's not a huge issue but I think it will be more aesthetically pleasing if I can reduce the icon size somehow? I have tried to introduce a line break to the caption using \n but this does not work. I would rather reduce icon size than value size.
Screenshot attached. Thanks.
I have just used different icons instead. I have gone with narrower icons that do not overlap with any caption or value characters. Seems like the easiest solution for now.

ggplot2 "borders" of filled points

So first: I'm wholly new to programming and this is my second(?) week of R, so apologies in advance.
I'm using pch=21 and using a fill color to show a factor, but I'd like to control the border size of the points.
Is there any way to increase the border size of pch 21? Or is there another way of adding borders to points that will allow me to control border size?
ggplot(mpg, aes(x=model,y=cty))+
geom_point(color="black",size=3,pch=21,aes(fill=manufacturer))
The reason this is a problem is because I'd like to use white filled points on a white background (it's just a common style in my field), but they're too hard to see unless I make the black border more distinct.

Resources