axes

df.hist() is not returning plot of desired size

df.hist() is not returning plot of desired size Question: I am using df.hist() to get plots of all the columns in my DataFrame. The problem is that it is not displaying my plots in desired dimensions I am using following code: plt.figure(figsize=(10,12)) df.hist() plt.show() it returns me with a grid of histograms but with a …

Total answers: 1

How to remove a colorbar

How to remove a colorbar Question: I want to remove a color bar from an axes in that way that the axes will return to its default position. To make it clear, have a look at this code (or better run it): import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable # …

Total answers: 1

Axes class – set explicitly size (width/height) of axes in given units

Axes class – set explicitly size (width/height) of axes in given units Question: I want to to create a figure using matplotlib where I can explicitly specify the size of the axes, i.e. I want to set the width and height of the axes bbox. I have looked around all over and I cannot find …

Total answers: 4

What are the differences between add_axes and add_subplot?

What are the differences between add_axes and add_subplot? Question: In a previous answer it was recommended to me to use add_subplot instead of add_axes to show axes correctly, but searching the documentation I couldn’t understand when and why I should use either one of these functions. Can anyone explain the differences? Asked By: Ivan || …

Total answers: 2

How can I accomplish `set_xlim` or `set_ylim` in Bokeh?

How can I accomplish `set_xlim` or `set_ylim` in Bokeh? Question: I create a figure in a function, e.g. import numpy from bokeh.plotting import figure, show, output_notebook output_notebook() def make_fig(): rows = cols = 16 img = numpy.ones((rows, cols), dtype=numpy.uint32) view = img.view(dtype=numpy.uint8).reshape((rows, cols, 4)) view[:, :, 0] = numpy.arange(256) view[:, :, 1] = 265 – …

Total answers: 4

matplotlib get axis-relative tick positions

matplotlib get axis-relative tick positions Question: I know that I can get the positions of my y-ticks by ax.get_yticks() (btw., is that the best/correct way to get them?). But I need the tick positions relative to the axis limits (i.e., between 0 and 1). What is the best way to get that? I tried ax.get_yticks(transform=ax.transAxes), …

Total answers: 1

Matplotlib pyplot axes formatter

Matplotlib pyplot axes formatter Question: I have an image: Here in the y-axis I would like to get 5×10^-5 4×10^-5 and so on instead of 0.00005 0.00004. What I have tried so far is: fig = plt.figure() ax = fig.add_subplot(111) y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=True) ax.yaxis.set_major_formatter(y_formatter) ax.plot(m_plot,densities1,’-ro’,label=’0.0<z<0.5′) ax.plot(m_plot,densities2, ‘-bo’,label=’0.5<z<1.0′) ax.legend(loc=’best’,scatterpoints=1) plt.legend() plt.show() This does not seem to …

Total answers: 2

Strange error with matplotlib axes labels

Strange error with matplotlib axes labels Question: I’m very new to Python and programming in general, so apologies in advance if I’m missing something obvious. I’m trying to plot a graph and label the axes, but every time I try to label the y axis an exception is raised. I wrote the code below in …

Total answers: 8

How to get a matplotlib Axes instance to plot to?

How to get a matplotlib Axes instance Question: I need to make a candlestick chart (something like this) using some stock data. For this I want to use the function matplotlib.finance.candlestick(). To this function I need to supply quotes and “an Axes instance to plot to“. I created some sample quotes as follows: quotes = …

Total answers: 2