Italicize and color legend manually for different graphs using same labels and colors - colors

I am trying to create multiple graphs that share the same legend.
I have found many ways to combine multiple graphs and it seems that ggarrange has the ability to create one shared legend for all that is supposed to be unique.
However I am having some problems when graphing since a few of the graphs do not have the same phyla (what defines the legend colors) present, but I would like them all to be the same colors throughout all of the graphs so the combined legend will have the correct colors.
For just one graph I would assign a color to the label manually like below
labs<-c("Arthropoda"="#FF66CC"
,"Cercozoa"="#FF6000")
and plot with the addition of scale_fill_manual(values=labs) and this seems to work
then I modified it so I could have portions of them italicized.
labsPhylum <-c('expression(paste(italic("Arthropoda")))'="#CC0000"
,'expression(paste(italic("Cercozoa")))'= "#FF6000"
,'expression (paste("unknown", ~italic("Eukaryota")))'= "#990000")`
However when I create a plot using ggplot and scale_color_manual() using the labsPhylum that I think should be italicized and colored I plot an empty graph with this warning so there is something vital I am not understanding here.
ggplot(data=sigtab_dil, aes(x=Species, y=log2FoldChange, color=Phylum))+
geom_point(size=2) +
scale_color_manual(values=labsPhylum)
Warning message:
Removed 9 rows containing missing values (geom_point).
Could someone please help me figure out where I am going wrong?
Thank you

Answered my own question
I realized I had to make separate vectors for breaks, labels, and values rather than combining them.
In short
colsPhylum <-c("Arthropoda"="#CC0000"
,"Cercozoa"= "#FF6000"
,"Chlorophyta"= "#CC9900"
labsPhylum <-c(expression(paste(italic("Arthropoda")))
,expression(paste(italic("Cercozoa")))
,expression(paste(italic("Chlorophyta ")))
breaksPhylum <-c("Arthropoda", "Cercozoa","Chlorophyta", "Choanozoa"
,"Ciliophora"
,"Cryptista"

Related

Bokeh hover info is behind some parts of the plot

I have a complex code, but it basically work like this:
I have multiple functions, that creat parts of the plot depending on inputs.
The main part of the plot is always shown, and depending on user inputs I add different subplots.
main_plot = gener_main_plot()
plot = add_some_box1(main_plot)
if some_user_iput:
plot = add_some_box2(plot)
plot = add_some_box3(plot)
The plot is generated, however the hover boxes are acting strange. Lets say the function add_some_box2 adds a hover to that part of the plot, but when I hover over that part, and if its big, it will be under the parts that were generated afterwards (add_some_box3).
Example:
How can I avoid this?
UPDATE: I am now using bokeh 1.0.1, however if I roll back to version 0.12.15, the problem is gone.

Can I bold invididual elements in y_range of a bokeh chart?

I would like to bold some of the values in my y_range but not others.
I have tried using p.yaxis.major_label_text_font_style = 'bold'. This bolds everything. I have also tried setting it equal to a column in a ColumnDataSource, but major_label_text_font_style does not accept that as an input.
# Orient y axis labels
p.yaxis.major_label_text_font_size = '18pt'
p.yaxis[0].major_label_text_font_style = 'bold'
p.yaxis.major_label_text_font = "calibri"
I would like some of the text in my y_range to be bold, but not all of the text
As of Bokeh 1.1 there is no built-in way to accomplish this. [1] The main reason is that, in general, tick labels and locations can be chosen dynamically, as a result of panning and zooming. There is no guarantee a tick you want to treat differently will actually be labeled or on the screen at all. I.e. it's not useful to say "make the third tick bold" if you have no idea of knowing or controlling what the third tick will be.
However, it might be possible to do something different in the case of categorical ticks, which are normally always all displayed, and so known up-front. I'd encourage you to file a GitHub feature request issue to discuss it.
[1] One could potentially create a custom extension Axis subclass to do this, but that would be non-trvial work, as Axis is one of the most complicated BokehJS objects.

Holoviews: separate figures with same coloring and scaling

Let's say that I have two Raster objects (or any other Holoviews object really). I can easily visualize one with appropriate color scaling, and I can do a layout to get both figures with the same scaling and coloring. What if I want to do two figures (e.g. because I need them on different pages), but with the same coloring and scaling so that the figures are comparable.
If there's no way to do this automatically, is there any way to access the relevant settings and then feed them manually to the second figure?
If you're using a notebook: The %opts line magic : IPython specific syntax applied globally [string format]http://holoviews.org/user_guide/Customizing_Plots.html and I think hv.opts works globally in script.
For both backends, you can do hv.renderer('bokeh').get_plot(your_element_variable).state (or replace bokeh with matplotlib) and get the original bokeh/matplotlib items.
Then you can use matplotlib's plt.getp() or bokeh's attribute calling (as I've done here https://github.com/ahuang11/holoext/blob/master/holoext/xbokeh.py#L501-L508) to get the base item's color/font/labels/etc.

flot - legend entries and stacked bars have reverse order

I ran across another small stacked bars issue: When filling the plot, flot adds the legend entries top-down and stacks the bars bottom-up. This way the legend is ordered exactly reverse from the bars.
The flot API allows for sorting the labels in the order they were added, alphabetically, or by providing a custom sorting function. I've tried providing a sorting function that always returns -1, so that the original sorting would be reversed but for some reason the sorted option seems not to be evaluated at all when using stacked bars. At least nothing I tried there (ascending, descending, false, function of my own) had any effect on the actual legend.
I've put together a test case at http://jsfiddle.net/YvGZu/1/ that illustrates the problem(s).
Edit: After some more testing ... could it be that legend-sorting is broken all together?
I coincidentally ran into the same issue as you within a couple of days. After a bit of hairpulling, I realized that the commit to handle legend sorting was quite recent (July 2012) and was not included in the version of jquery.flot.js that I was using.
From inspecting the flot resource on your Fiddle, it appears the same is true for you. If you update your flot js file to one that includes the sorting algorithm, your issue will likely be resolved, as mine was. (Well, I manually patched, since I had other experimental changes.)
I'm going to guess that you will next encounter the same roadblock as me, which was that the sorting code as it exists only sorts alphabetically, or with a comparitor that can only examine the label text and colour code. That was not good enough for me -- I wanted to assign an arbitrary sort order server side. In order to accomplish this, I added a hidden sort order string to my series labels:
label: '<a class="hiddenOrder">2</a>foo'
And then style those a blocks in the Flot placeholder to hidden (edit: also need the style to apply to tooltips, which are not contained within the Flot placeholder).
#flotPlaceholder a.hiddenOrder,
#flotTooltip a.hiddenOrder
{display:none;}
I forked your fiddle and included my ordering technique so you could try it out, but unfortunately it looks like my resource links to GitHub aren't working within the fiddle. You should be able to get it rolling locally, though.
Good luck!

How do I put tick labels inside of a line graph in Flot

I essentially want to have the tick labels sitting inside the graph in their own column. Similar to how Campaign Monitor graphs are. But I can't find a way to do this. Is it possible?
In current versions of flot, the only thing you can control about the ticks is the contents and the label class (all ticks have the class "tickLabel").
I think with those two abilities, you cannot do what you're looking for.
Check out this flot bug for some code modifications that might get you to what you want: http://code.google.com/p/flot/issues/detail?id=191
How is this question different than this one?
jQuery Flot data/axis labels on top of graph
For that one, someone suggests negative labelMargins

Resources