Manipulate Labels in Gadfly Charting Julia - julia

I have a line chart in Gadfly using the label = "string vector" option. My question is how can I manipulate the location and size of the labels printed on the chart? I want to adjust the location of the printed labels upward slightly and increase the font size. How can I do this?
From the Gadfly documentation, I think it should be an option within 'Theme', but I can't seem to figure this out.
http://gadflyjl.org/themes.html
Thank you

As mentioned by #jfish003 there is a named argument in Theme, major_label_font_size which can be set as needed. The font size of minor label can also be set. Note that the argument is of type Measure, a simple example,
julia>plot(x=rand(10), y=rand(10), Theme(major_label_font_size=15pt))

Related

How do you change the font of `Plots.text()` in julia?

I am using the Plots.text function from the Plots.jl package to annotate points in my plot. It appears that changing the plot(..., fontfamily="Computer Modern") does note seem to have an effect on these annotations.
Plots.text creates a text object including styling information. It is therefore necessary to change the font directly
Plots.text("abcde", "Arial")
seems to work

Increase Labelsize in Julia Plots

I am creating a plot using Plots in Julia. I was trying to increase the size of the labels and also the values on the axes but couldn't find the right keyword arg (I thought it was annotationfontsize but that doesn't seem to work). Does anyone know the right arg?
I think you're looking for guidefontsize and tickfontsize. You can check all the axis attributes in the documentation. For example,
julia> plot(rand(10); xtickfontsize=5, xlab="Big label, small tick labels", xguidefontsize=20)
will give you something like

Labelling X and Y axis in Dymola plot

I have drawn a plot using "plotArrays" function in Dymola. I would like to label X-axis in meters(Ideally, I need it to be flexible so that I can later change it to millimeters, micrometers, etc..). I want to label Y-axis similarly in volts which I have done already using
plotArrays(x_axis,phie,legend=names,units=fill("V",size(phie,2)));
and I can read the values in volts and also change to mV etc.. However, its not 'visible' in Y-axis as you can see in the plot below. So, How can I label the axes separately?
Thanks a lot!
I don't know any more efficient possibility than this:
createPlot(id=1, erase=false, grid=true, leftTitleType=2, leftTitle="myLabelY", bottomTitleType=2, bottomTitle="myLabelX")
with:
id being the number shown in the original plot
erase=false to ensure that the content is not modified
grid=true (re-)enabling the grid
*TitleType=2 saying that there is a custom title
*Title being the string to put there
This will result in the plot being resized to the default size. You can use plotSetup() to get the current setup, including position, which you can then pass (manually) to the createPlot() command to result in the original size again.
Not very elegant, but I don't know any other possibility...

R Make barchart with unicode symbol instead of bars

I'd like to plot a (kind of) barchart, but rather than using bars, I'd like to use a unicode symbol. Is this possible?
I know how to use a unicode character as a symbol (points); for example:
plot(1,1,pch=-0x0001F3E2, cex=5, col="gray30")
but how can make the symbol substitute the bars?
EDIT:
As suggested by Eric, I'll try to write a minimal reproducible example...
Given variable x:
x <- c(2,3,4,2,1)
barplot(x)
I want to produce a barplot using custom symbols rather than bars. Something like:
plot(1:5,rep(0,5),pch=-0x0001F3E2, cex=x, col="gray30")
The problem is that I am not able to vertical align sysmbols as I can do with text:
plot(1:5,rep(0,5),type="n", ylim=c(0,1),bty="n")
text(1:5,0,"A",cex=c(2,5,3,3,1),adj=c(0.6,0))
So, a sort of solution to my problem, although not ideal, is to use
some custom system font with package extrafont.
For example, using font "Destiny's Little Houses" (http://www.dafont.com/destiny-little-hous.font)
I am able to produce some nice infographics:
plot(1:5,rep(0,5),type="n",ylim=c(0,1),bty="n")
text(1:5,0.1,"A",cex=c(2,5,3,3,1),adj=c(0.6,0),family="Destiny's Little Houses")
So, rather than having bars I have an image whose size changes according to some variable (using "cex").
This is not ideal, first of all because I'd like to be able to import any image (ex. using the png package).
So, is it possible to:
import an image file and use it as the symbol in plot (rather than one of the available sysmbols using pch)?
Vertical align symbols so that I get a kind of custom barchart?
Thanks
António
Here's a somewhat hackish start (might not be helpful as I don't know what your data looks like).
counts <- table(mtcars$gear)
foo <- barplot(counts, col = c("white", "white", "white"), border=c("white"), axes=F, xaxt="n")
points(foo, counts-.5, pch = -0x0001F3E2, cex=2, pos=3)
Remove , axes=F, xaxt="n" to get the labels and axis back.

Both custom tickmarks AND custom fontface in ggplot2

Apologies if this is straightforward or has already been answered, but I've searched high and low and haven't been able to find a solution anywhere.
I'm using ggplot2, trying to (1) specify custom tick marks to an axis which involve subscripts, and (2) trying to specify that some of these tick marks should be bold and others italic. I know how to do (1) and (2) separately, but when I try to do both together, only (1) succeeds.
y.labels<-c(expression(A[Subscript]),expression(B^Superscript))
y.face<-c("bold","italic")
testdf<-data.frame(x=rnorm(100),y=1:2)
Bold/italics don't appear when I supply custom labels:
ggplot(testdf,aes(x=x,y=y))+geom_point()+
scale_y_discrete(label=y.labels)
theme(axis.text.y=element_text(face=y.face))
But when I let the labels take their default values, bold/italics do appear:
ggplot(testdf,aes(x=x,y=y))+geom_point()+
theme(axis.text.y=element_text(face=y.face))
As far as I can tell, the problem doesn't have anything to do with subscripting/superscripting,
even though that is my aim, here (and which is why I'm passing the tick marks directly, rather than creating a factor variable with the desired labels, which does work). This doesn't work, either:
ggplot(testdf,aes(x=x,y=y))+geom_point()+
scale_y_discrete(label=c("Custom1","Custom2"))+
theme(axis.text.y=element_text(face=y.face))
If anyone can explain what's going on, here, and provide a solution whereby I can do both, I'd be much obliged. Thanks.
plotmath doesn't honour fontface, you want to use bold() or italic() in your expressions,
y.labels<-c(expression(bold(A)[Subscript]),expression(italic(B)^Superscript))
ggplot(testdf,aes(x=x,y=y))+geom_point()+
scale_y_discrete(label=y.labels)

Resources