How to make interactive Bokeh Histograms? - bokeh

I have been working with bokeh for a little while now and when showing people data they really seem to love being able to interact with the data. I've managed to acheive this via bokeh serve, but only for scatter diagrams. Can this be done with histograms?
The problem, I think, is that as a high-level chart, Histogram() won't take a ColumnDataSource as its argument, which seems to be what the interactivity is based around. I'm not very clued up about this, so any help or comment on workarounds is appreciated.

I fairly new to Bokeh as well - so there may be a better way, but my quick work around was to create my histogram with multiple rectangle glyphs. The only catch is that rect uses the y value passed to it as the center of the glyph, rather than its absolute height.
Something like:
plot.rect(x, y=bar_height/2, width = 1, height = bar_height, source= source_data)
Works for me.

Related

Removing grid lines in a map and smoothing in maps

I am trying to remove the grids on my map. I used several commands for example: plt.grid(), plt.rcParams["axes.grid"] = False but nothing happens, the map produced as is with the grids. Is there any possible way to remove the grids?
Another thing also, how can I make my plot to be smoothed instead of having the data as blocks (see below a sample of the plot).
enter image description here
Please assist in this regard.
Truly appreciate your time.
Thank you.

Remove plot element without replotting everything else in R (Shiny)

This is not an specific question, but mostly a "looking for suggestions", since any kind of answer is welcome.
I built a huge website using pure shiny in R, but a really small thing is bothering me..
I'm plotting some elements over an image, let's say.. rectangles (could be anything), and interact with those elements using their position on the image. One of the actions is deleting some of those elements, but -as far as my understanding of R plotting system is- that can't be done, since an element plotted in R can't be removed, so my workaround is basically "plotting everything else" but the element i just deleted.
So, my question is, is there any way to "remove" an object in a plot without having to replot everything else (basically not making a new plot with everything but the deleted element)?
Thanks in advance!

How to plot a large number of vbar in a Bokeh figure

Hi I am trying to modify the example code here
https://docs.bokeh.org/en/latest/docs/gallery/bar_mixed.html
I removed the toolbar_location=None so that the Bokeh toolbar can show, also I made factors array very large.
I would like to see a figure that I can pan/scroll to view more data rather than it is doing right now-congested all the bars in the fixed width.
How to do that?
As of version 0.12.16 Bokeh only supports initially showing all the factors. There is no mechanism to show only some subset. You can open a GitHub issue if you would like to discuss adding this as a feature.

3D Line Plot with Datavisualization

I am looking for a way to draw a 3d line plot. Preferably I would like to use the datavisualization framework, but it does not seem to provide this out of the box.
I experimented a little bit and ended up using 3D surface plots (Surface3D) displaying the lines as surfaces (i.e. ribbons) like this:
While this works and looks okay in above picture the thickness of the line depends on the perspective. Rotating the plot always allows to find the angle where the line disappears since it has not thickness:
Is there a type of plot that would be better suited for this? I tested the bars which don't perform well for lots of samples and don't look nice in my application. I also tested scatterplots which are not suitable either.
If there isn't: Where would I start to implement this myself on top of the existing classes in the datavisualization framework? I am thinking about adding another surface "ribbon" in z direction, however that seems a little hackish.
I used the technique described as hackish above. While I am not too happy about the approach the overall look is quite okay:
So basically each data line consists of three QSurfaceDataRows that together form two 90° ribbons as can be seen here:

Changing the font size in a DAG in R

I'm building a Bayesian network (DAG) in R, it has several nodes stemming from one parent, so it has a lot of nodes.
I can't seem to figure out how to increase the font size of the node labels (won't let me post image).
To plot it, I've just done plot(dag_pigment).
Where the input is this:
dag_pigment<-dag(c("pigment","1800407"),c("pigment","12203592"),c("pigment","12896399"),c("pigment","3829241"),c("3829241","12913832"), c("pigment","1408799"), c("1408799", "12913832"),c("pigment","683"),c("pigment","10777129"),c("pigment", "28777"),c("pigment", "16891982"),c("pigment", "6119471"), c("pigment", "1426654"),c("pigment", "1800414"),c("pigment", "4959270"),c("pigment", "2378249"),c("pigment", "12821256"),c("pigment", "1805007"))
I've tried using cex within the plot function, and all the other subcategories (cex.main, cex.sub,etc.)
I've tried using ps, and I've tried using par like par(ps=20,cex=1,cex.main=1).
Are there other functions I should be trying? A different plot function?
Appreciate any help! I'm still pretty new at figuring these things out.
Ok, I actually figured this out after several hours, so, I'm posting the answer to be helpful for anyone else who might be looking.
You have to use the attrs function:
dag_pigment.cust<-plot(dag_pigment,attrs=list(node=list(fontsize=60)))
and this increased the font.

Resources