Bokeh logarithmic scale for Bar chart

2024/9/22 7:37:47

I know that I can do logarithmic scales with bokeh using the plotting API:

p = figure(tools="pan,box_zoom,reset,previewsave",y_axis_type="log", y_range=[0.001, 10**22], title="log axis example",x_axis_label='sections', y_axis_label='particles'
)

However, I can't figure out how to get this to apply to high level charts such as Bokeh.charts.Bar. In general I'm having a lot of trouble grokking what to relationship is between a Chart and a figure. Can anyone point me to some documentation on this or explain how to modify things which are only exposed through figure and have them affect my Chart.

Answer

I am specifically going to update the documentation describing the different Bokeh APIs this week, but for now, the three Bokeh APIs in increasing order of "level":

  • models interface: lowest level API, base serialization layer, must put everything together everything manually
  • glyphs interface (bokeh.plotting): mid-level API, easily create plots/figures centered around visual glyphs with attributes tied to data
  • charts interface (bokeh.charts): high level API for canned/schematic statistical charts, e.g. "BoxPlot" and "Histogram".

There is no particular relation between figure and the various chart functions, except that they both produces subclasses of Plot as output.

I am not sure it is currently possible to add a log axis to the Bar plot in "charts" interface (that would be a reasonable feature to add). However it would be simple to make a boxplot "by hand" using the middle "glyphs" interface using rect or quad glyphs. Here is a quick example:

from bokeh.plotting import figure, output_file, showoutput_file("bars.html")p = figure(title="log bar example", y_axis_type="log")p.quad(bottom=0, top=[10**5, 10**8, 10**3], left=[0, 2, 4], right=[1,3,5]
)show(p)  
https://en.xdnf.cn/q/71972.html

Related Q&A

Can I control the way the CountVectorizer vectorizes the corpus in scikit learn?

I am working with a CountVectorizer from scikit learn, and Im possibly attempting to do some things that the object was not made for...but Im not sure.In terms of getting counts for occurrence:vocabula…

mod_wsgi process getting killed and django stops working

I have mod_wsgi running in daemon mode on a custom Linux build. I havent included any number for processes or threads in the apache config. Here is my config:WSGIDaemonProcess django user=admin WSGIPro…

Reindex 2nd level in incomplete multi-level dataframe to be complete, inserting NANs on missing rows

I need to reindex the 2nd level of a pandas dataframe, so that the 2nd level becomes a (complete) list 0,...,(N-1) for each 1st level index.I tried using Allan/Haydens approach, but unfortunately it on…

ImportError: cannot import name _gdal_array from osgeo

I create a fresh environment, install numpy, then install GDAL. GDAL imports successfully and I can open images using gdal.Open(, but I get the ImportError: cannot import name _gdal_array from osgeo er…

How do I insert a map into DynamoDB table?

I have the following line of code :table.put_item( Item={filename : key, status : {M : iocheckdict }})The iocheckdict looks like this:{A: One, C: Three, D: Four, B: Two, E: Five}So, when I am running t…

How to redirect django.contrib.auth.views.login after login?

I added django.contrib.auth.views.login everywhere in my webpage, for that I had to load a templatetag (that returns the AuthenticationForm) in my base.html. This templatetags includes the registration…

How to do windows API calls in Python 3.1?

Has anyone found a version of pywin32 for python 3.x? The latest available appears to be for 2.6.Alternatively, how would I "roll my own" windows API calls in Python 3.1?

Returning the outputs from a CloudFormation template with Boto?

Im trying to retrieve the list of outputs from a CloudFormation template using Boto. I see in the docs theres an object named boto.cloudformation.stack.Output. But I think this is unimplemented functi…

numpy.array of an I;16 Image file

I want to use TIFF images to effectively save large arrays of measurement data. With setting them to mode="I;16" (corresponding to my 16 bit data range), they yield 2MB files (~1000x1000 &quo…

Namespace packages and pip install -e

I have a ns.pkg2 package that depends on ns.pkg1 package. I make a fork of it, publish it to git and want to install my version into my virtualenv. I use pip install -e mygit and end up with ns.pkg in …