Removing axes margins in 3D plot

There is not property or method that can modify this margins. You need to patch the source code. Here is an example: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np ###patch start### from mpl_toolkits.mplot3d.axis3d import Axis if not hasattr(Axis, “_get_coord_info_old”): def _get_coord_info_new(self, renderer): mins, maxs, centers, deltas, tc, highs = self._get_coord_info_old(renderer) … Read more

How to get a matplotlib Axes instance

Use the gca (“get current axes”) helper function: ax = plt.gca() Example: import matplotlib.pyplot as plt import matplotlib.finance quotes = [(1, 5, 6, 7, 4), (2, 6, 9, 9, 6), (3, 9, 8, 10, 8), (4, 8, 8, 9, 8), (5, 8, 11, 13, 7)] ax = plt.gca() h = matplotlib.finance.candlestick(ax, quotes) plt.show()

Changing the tick frequency on the x or y axis

You could explicitly set where you want to tick marks with plt.xticks: plt.xticks(np.arange(min(x), max(x)+1, 1.0)) For example, import numpy as np import matplotlib.pyplot as plt x = [0,5,9,10,15] y = [0,1,2,3,4] plt.plot(x,y) plt.xticks(np.arange(min(x), max(x)+1, 1.0)) plt.show() (np.arange was used rather than Python’s range function just in case min(x) and max(x) are floats instead of ints.) … Read more

What are the differences between add_axes and add_subplot?

Common grounds Both, add_axes and add_subplot add an axes to a figure. They both return a (subclass of a) matplotlib.axes.Axes object. However, the mechanism which is used to add the axes differs substantially. add_axes The calling signature of add_axes is add_axes(rect), where rect is a list [x0, y0, width, height] denoting the lower left point … Read more

Strange error with matplotlib axes labels

I had this same issue when working in iPython notebook. I think it can be re-created as follows: import matplotlib.pyplot as plt plt.ylabel=”somestring” # oh wait this isn’t the right syntax. … plt.ylabel(‘somestring’) # now this breaks because the function has been turned into a string Re-starting the kernel or re-importing the libraries restores plt.ylabel … Read more

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

The axes size is determined by the figure size and the figure spacings, which can be set using figure.subplots_adjust(). In reverse this means that you can set the axes size by setting the figure size taking into acount the figure spacings: import matplotlib.pyplot as plt def set_size(w,h, ax=None): “”” w, h: width, height in inches … Read more