Issues adjusting space in LyX when generating sticker labels using package labels - lyx

I am trying to make stickers labels with LyX using the package "labels".
The LyX file is here:
LyX input file
And the result is:
They do not fit well in the space, so I am trying to adjust them. The one in the left has a big inter line space. I have tried to remove it but it is impossible Where is that option?. In addition, I tried to centre the first line, but all of them are centred. How can I mark each of the lines as an independent block?
Regarding the label in the right, although it does not fit the label, it is more adjusted. However, for example, the line containing "Best before: 16/12/16" should continue with "Amount: 100 gr ...", that is, there should not be a new line. Is there anything I that I am missing? FIXED. See below.
Thank you very much for your help.

FIX for the line breaks in label on the right: set Tools→Preferences→Output→General→Output line length to 0

Related

How can I adjust the position of tip labels relative to tree tips on a phylogenetic tree?

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.

R: text of legend falls outside of plot when exporting to PDF

When I add a legend to my R plot (using the legend() function), then it works in Rstudio, but when I export the plot as a PDF with a different size, then sometimes the text inside the legend is larger than the legend box itself.
What is going on here and how do I fix it?
If I export the image with a larger width, then the legend box becomes larger too and manages to contain its text, but this is silly: I want the legend box and its text to automatically adjust to whatever width I choose, no matter how small it is.
And please don't recommend ggplot2.
As #Gregor said - you should use pdf(). I am merely adding his suggestion as an answer. Your code would be something like this:
pdf("picture.pdf", width=6, height=6)
plot(...)
legend(...)
dev.off()
Where pdf() opens a new device for plotting (of course you have to set file name as well as dimensions according to your needs), and dev.off() closes the device writing everything to a file.
I am not sure what causes the issue with legend in R-studio. But on my machine I noticed that legends sometimes have issues with updating after resizing the device. Probably this is something related.

Displaying multipanel R figure

I have been working on a multi-panel figure in R. It displays a lot of plots/graphs... a number of rows and a number of columns. When I add titles to the ONLY the top row, they appear above the output rendering. Either it's too far above or it gets cut off.
The multipanel is pretty big, about six rows with three columns each. As every column represents the same thing, I figured to add titles above all of them. The titles at first were directly on the graph so I decided to raise them using the following:
title(main = "Title Example ", cex.main=1.7 , line = 1)
This elevates things nicely. But it goes way too high.
Previously I had issues with the size being too large. It was solved using one of the following two:
par(mar=c(1,1,1,1))
or
dev.new(width=16,height=10)
The titles just appear above the stuff. Any suggestions for what can be done to fix this?
I am hoping that the final output could just "lower" everything by a little bit.
But also, the output generation panel does not have a "scroll" sort of element. Would be nice if I can do that too... The monitor has only so much size, which does not fit the 6 x 3 fully.
It looks like it was fixed by using "par(mar=c(0.5, 7, 1.5, 0.5))"... this code increased the margin and so it worked.

Young diagrams in Latex - large strips and braces

I am trying to write a few properties of Young diagrams using Latex and am trying to make the symbolic notation as clear as possible but I encountered a few problems.
I would like to study functions whose arguments are Young diagrams, for example long vertical or horizontal strips. I would like to draw a vertical strip by drawing 2-3 blocks at the top, followed by vertical dots and finishing with a single block at the bottom, all in a brace to the left (or right) saying that there are k blocks.
I tried using the \young environment but it doesn't seem to let me skip vertical strips or draw empty blocks. the ytableau environment does, but I don't know how to insert the dots in the place of the skipped blocks. Also, when considering a function of two arguments, the ytableau environment kinda messes up the centering and gives the top block as the center of the line, which doesn't look good... Also, in the later stages I plan to distinguish between the first few blocks and so would like to put into a brace only a few of the first (or the last) blocks.
To give it a more visual explanation, this is something I would like:
And the best I got so far is this:
I would really appreciate all the help and suggestions.

Set Legend Spacing in ggplot2

I am trying to create a plot in R using ggplot2. The figure looks great when displayed in R, but when I write it to pdf the labels in the legend slightly overlap the different color lines they are defining. How do I add white space between entries so that this does not happen?
Without code example it is hard to say, but if you don't see this problem in the R display and you see it in the pdf, you can try to increase the pdf output size. When rendering a pdf, the font size is kept and the elements of the graph are more squeezed if the output size is smaller than the displayed one.
p<-ggplot(mpg,aes(cyl,year))+geom_point()
ggsave('yourfile.pdf',p,width=10,height=10) # default is 7 on my install
I don't know if it is possible to change the spacing, but I don't see any parameters for that in the theme() or element_text() documentation

Resources