2

I'm trying to figure out how to change the font size for text written using compose.jl. The text is being written within a Gadfly plot using Guide.annotation, and I can see how to change other font sizes within the plot (i.e. key_title_font_size etc.) but there doesn't seem to be a "default_font_size" parameter within Gadfly. I'm sure compose() must have some font size parameter, but I can't see what it is. My code is here:

modelplot = plot(all_data_to_plot, x=:value,y=:sample, colour=:PFAM_Model, Geom.bar(position=:dodge,orientation=:horizontal),
Guide.ylabel(""),
Guide.xlabel("rpoB equivalents"),
Theme(bar_highlight=color(colorant"black"),
key_position=:none,
default_color=color(colorant"black"),
panel_stroke=color(colorant"black"),
grid_color=color(colorant"gray"),
major_label_font="Helvetica",
major_label_color=color(colorant"black"),
key_title_color=color(colorant"white"),
minor_label_font="Helvetica",
key_label_font="Helvetica",
minor_label_color=color(colorant"black")),
Guide.annotation(compose(context(),
text(all_data_to_plot[:value]+0.01,all_data_to_plot[:read_plot_pos],all_data_to_plot[:reads],[hleft])))
)

I'd be grateful for anyone who could point me in the right direction.

EDIT: I tried adding a "point_label_font_size" within Gadfly, but that doesn't change any of the font size for the text printed within Guide.annotation, so I still don't know how to do this:

modelplot = plot(all_data_to_plot, x=:value,y=:sample, colour=:PFAM_Model, Geom.bar(position=:dodge,orientation=:horizontal),
Guide.ylabel(""),
Guide.xlabel("rpoB equivalents"),
    Theme(bar_highlight=color(colorant"black"),
    key_position=:bottom,
    default_color=color(colorant"black"),
    panel_stroke=color(colorant"black"),
    grid_color=color(colorant"gray"),
    major_label_font="Helvetica",
    major_label_color=color(colorant"black"),
    key_title_color=color(colorant"white"),
    minor_label_font="Helvetica",
    key_label_font="Helvetica",
    minor_label_color=color(colorant"black"),
    point_label_font_size=32pt),
Guide.annotation(compose(context(),
text(all_data_to_plot[:value]+0.01,all_data_to_plot[:read_plot_pos],all_data_to_plot[:reads],[hleft])))
)
Ian Marshall
  • 709
  • 1
  • 5
  • 14

1 Answers1

1

Unfortunately, Gadfly.jl's default theme is hard coded and cannot be overwritten. You can overwrite your Gadfly installation at ~/.julia/v.0.4/Gadfly, but only for your own personal use.

You could also try using a personal type (sa MyPlotType) that re-writes the Gadfly.Theme's variable each time you create a plot, but that would involve also extending several functions, which kind of misses the whole point of "just setting the default value".

Felipe Lema
  • 2,700
  • 12
  • 19
  • Thanks for that, but I can't see where in the theme the font size is specified for text within annotations (i.e. not a specific axis label or title font size, just font size for extra text written on using Guide.annotation along with the compose function). There should be some way of specifying font size within a compose.jl function, shouldn't there be? – Ian Marshall Dec 01 '15 at 08:47
  • that would be [`point_label_font`](https://github.com/dcjones/Gadfly.jl/blob/master/src/theme.jl#L131). Like I mentioned, there are other ways to wrap functions around Gadfly API, but I can't say how many LOC will it take – Felipe Lema Dec 02 '15 at 14:27