QFontMetrics lacks baseline() method - qt

QFontMetrics has accent() and descent() methods, but it lacks the base line.
How do I get the distance from the bottom to the base line?
EDIT:
Rephrased in other words, I need to know how to calculate the base line to draw the text as it should go according to font standards, for example:
painter->drawText(QPoint(x,fontmetric.height()-fontmetric.descent()),my_text);
I am calculating the base line correctly?

Related

How to avoid collision of text in basic R?

text() puts text at specified coordinates. But some texts may overlap each other. How to wiggle the position of the text automatically so that they don't overlap?
The solution must be in basic R instead of using another R package as I will need to combine this with other basic R drawing commands to customize my drawing. Or the solution should provide a way to compute the wiggled coordinates. It should not directly draw the texts so that I can not combine it with my other drawing code in basic R.

Change plot window size in Julia notebook

I am using Julia notebook and making plots using basic Plots package.
A plot looks good, except its entire size.
I can change the plot size and font size of labels individually. But it becomes less readable unless I change the font size and line width for every component.
So is there a way to change the size of a plot as a whole? I also hope I can change it by default.
To answer your original question in the title, you can change the size of the Plot Window by specifying the size attribute as you already are in your code. See here: http://docs.juliaplots.org/latest/basics/ for more details.
As pointed out by Rashid, you can use the scalefontsize function to scale the font size. You can also scale the thickness by setting the thickness_scaling attribute, see here for more details: http://docs.juliaplots.org/latest/generated/attributes_plot/
To be clear, there is not currently a unified way to scale a plot in the way you are looking for it right now, it has to be done manually (though it would be great to have this unified scaling). I opened a feature request for this here: https://github.com/JuliaPlots/Plots.jl/issues/3153

How to write units raised to some number in titles of axes in an IDL plot window?

The titles of axes in a plot usually consists of units of some physical parameter. How do we represent such a unit, especially when it contains some letter raised to the power some number?
For example, if the x-axis represents velocity, how can we represent m s^-1 properly as the xtitle?
It depends on the graphics system you are using.
If you are using function graphics, then you can do something like:
IDL> p = plot(/test, ytitle='velocity $m s^{-1}$')
If you are using direct graphics, then do:
IDL> plot, findgen(10), ytitle='velocity m s!E-1!N'
See the Doc Center for a complete listing of the embedded graphics format codes.
There are also helpful library routines to help with direct graphics.

R {wordcloud} package, what do the values in scale represent?

This seems like a simple question, but I can't seem to find an answer anywhere. In the R {wordcloud} package, the wordcloud function, there is a scale value that you can enter. The full documentation (here: https://cran.r-project.org/web/packages/wordcloud/wordcloud.pdf) says: "A vector of length 2 indicating the range of the size of the words."
I can't seem to make any sense of the values though, and I can't find any other documentation. For instance, examples have scale=c(4,.5) or scale=c(8,.3). What do these numbers mean?
I've messed around with different values a bit, but I can't seem to figure out the pattern.
Thanks in advance for any help,
Seth
wordcloud internally calculates
size <- (scale[1] - scale[2]) * normedFreq + scale[2]
where the 2 elements of size are used to set strheight and strwidth. These are graphics values described as follows:
These functions compute the width or height, respectively, of the
given strings or mathematical expressions s[i] on the current plotting
device in user coordinates, inches or as fraction of the figure width
par("fin").
So, long story short, it's height and width.

Placing grid tables in R

I want to use grid.table() in an existing plot in R. However I can't locate this table on the right side of my chart. So the thing is:
First of all, I make an histogram of my data:
hist(as.numeric(unlist((vels[counts]))),freq=F,
col="gray",border="black",ylim=c(0,0.15),
xlab=paste(names(vels)[counts]),
main=paste("Weibull fitting",names(vels[counts])))
After that, I have implemented a function that plots in an existing chart the Weibull curve giving both parameters A and K:
plot_weibull(K_value,A_value)
And finally I want to place a data.frame using the grid.table() because it shows the cells in a very pretty form, and you can use italic and bold text in cells.
grid.table(round(values,3),cex=0.75,show.rownames=T,
show.colnames=T,show.hlines=T)
The problem is that this table appears in the center of the device in front of the histogram and the curve, and I want it to be in the right side.
After all, I would like to know a tool that clicking on the graph, I would receive the area under my Weibull curve.
The hist function is base graphics and the grid.table function is grid graphics. The 2 graphics systems do not play nicely together without extra effort (as you have noticed).
The easiest fix is to use the addtable2plot function from the plotrix package rather than grid.table. It may not look the same but it would be simple.
Another option is to use a grid graphics function to create the histogram, such as something from the lattice or ggplot2 packages (both can do histograms), then create a specific viewport using grid graphics functions and use grid.table to put the table into that viewport.
Last, if you really want to mix them then see the gridBase package for ways to mix grid and base graphics.

Resources