0

I'm trying to develop some graphs using bqplot in Python but I'm having some questions regarding the documentation and where I can find the appropriate options to personalize a graph. I'm trying to make a boxplot graph and chenge the axes_options, but I don't find anywhere what's the possible options of 'axes_options' argument.

Here's a toy example of the boxplot that I want to change:

import bqplot.pyplot as plt
x = [1]
y = [[7,9,7,6,4,3,2,5,6,7,1,2,3,1,4.4,7.7]]
fig = plt.figure()
# add x and y labels using axes_options
axes_options = {'x': {'label': 'X'}, 'y': {'label': 'Variable Value'}}
boxes = plt.boxplot(x, y, box_fill_color='gray', outlier_fill_color='black', axes_options=axes_options)
fig

How can I, for example, change axes limits inside the axes_options dictionary? And how can I find the available options?

  • does bqplot actually have a `boxplot`? – ImportanceOfBeingErnest Aug 17 '18 at 17:26
  • bqplot has two API: one inspired in matplotlib (which is from my example) and another one called verbose API. They explain this here in this notebook: https://hub.mybinder.org/user/bloomberg-bqplot-g3kywf1d/notebooks/examples/Introduction.ipynb – Renan Xavier Cortes Aug 17 '18 at 17:35
  • The link isn't working, but I suppose you mean [this one](https://github.com/bloomberg/bqplot/blob/4722f21209cd8a1b6baa818e556b4cea4d5373e0/examples/Marks/Pyplot/Boxplot.ipynb)? Is there a reason you don't want to use `plt.ylim()`? – ImportanceOfBeingErnest Aug 17 '18 at 18:09
  • I guess the available options are listed in [bqplot.axes.Axis](https://bqplot.readthedocs.io/en/latest/_generate/bqplot.axes.Axis.html). It doesn't look like it's possible to change the axis limits with this though. – ImportanceOfBeingErnest Aug 17 '18 at 21:13
  • Hi! Yes, I actually changed my code to use plt.ylim and it worked :) However, I'm still having another issue which is a 'panning' problem of bqplot. Whenever I pan the boxplot, the axes update but the boxplot doesn't move. But I think this is another issue that I should open. Thanks! – Renan Xavier Cortes Aug 20 '18 at 12:25

1 Answers1

0

One way I achieve this is to access the Scale that the Axis is attached to once the figure has been instantiated, e.g. fig.axes[0].scale.min = 0, or fig.axes[0].scale.max = max(data).

I have come across some issues with boxplot generally, and as you highlighted on Github. But this method seems to work well for other chart types e.g. Scatter.

ac24
  • 5,325
  • 1
  • 16
  • 31