You can use the Axes.set_yscale
method. That allows you to change the scale after the Axes
object is created. That would also allow you to build a control to let the user pick the scale if you needed to.
The relevant line to add is:
ax.set_yscale('log')
You can use 'linear'
to switch back to a linear scale. Here’s what your code would look like:
import pylab import matplotlib.pyplot as plt a = [pow(10, i) for i in range(10)] fig = plt.figure() ax = fig.add_subplot(2, 1, 1) line, = ax.plot(a, color='blue', lw=2) ax.set_yscale('log') pylab.show()
Related Posts:
- Log to the base 2 in python
- Understanding the main method of python [duplicate]
- ImportError: DLL load failed: The specified module could not be found
- ImportError: DLL load failed: The specified module could not be found
- What is the difference between importing matplotlib and matplotlib.pyplot?
- Python Math – TypeError: ‘NoneType’ object is not subscriptable
- TypeError: only size-1 arrays can be converted to Python scalars (matplotlib)
- Showing an image with pylab.imshow()
- ImportError: No module named matplotlib.pyplot
- What is the necessity of plt.figure() in matplotlib?
- How do you change the size of figures drawn with Matplotlib?
- PermissionError: [Errno 13] in Python
- Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as plt”?
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- ImportError: No module named matplotlib.pyplot
- “If not” condition statement in python
- syntaxerror: “unexpected character after line continuation character in python” math
- How can I sort a dictionary by key?
- Plotting a 2D heatmap with Matplotlib
- Save plot to image file instead of displaying it using Matplotlib
- How to plot ROC curve in Python
- Python Logic of ListNode in Leetcode
- How to plot a histogram using Matplotlib in Python with a list of data?
- How can I write a `try`/`except` block that catches all exceptions?
- In Matplotlib, what does the argument mean in fig.add_subplot(111)?
- How can I plot a confusion matrix? [duplicate]
- Error in Python script “Expected 2D array, got 1D array instead:”?
- Python Key Error=0 – Can’t find Dict error in code
- Relative imports for the billionth time
- what does the __file__ variable mean/do?
- How to change the font size on a matplotlib plot
- How do I set the figure title and axes labels font size in Matplotlib?
- How to customize a scatter matrix to see all titles?
- Matplotlib automatic legend outside plot
- How can one display an image using cv2 in Python
- Matplotlib automatic legend outside plot
- Changing the “tick frequency” on x or y axis in matplotlib?
- matplotlib error – no module named tkinter
- Plot pie chart and table of pandas dataframe
- ModuleNotFoundError: No module named ‘matplotlib’
- Add Legend to Seaborn point plot
- Pythonic way to create a long multi-line string
- Proper shebang for Python script
- TypeError: ‘DataFrame’ object is not callable
- How to add title to subplots in Matplotlib
- Python setup.py develop vs install
- How to clamp an integer to some range?
- How to change a ‘LinearSegmentedColormap’ to a different distribution of color?
- Create own colormap using matplotlib and plot color scale
- How to plot time series in python
- How to increase plt.title font size?
- How to make a 3D scatter plot in matplotlib
- How to draw vertical lines on a given plot in matplotlib
- Modify the legend of pandas bar plot
- Changing the “tick frequency” on x or y axis in matplotlib
- How to extract the substring between two markers?
- How can I set the aspect ratio in matplotlib?
- Remove xticks in a matplotlib plot?
- Is there an operation for not less than or not greater than in python?
- Simple prime number generator in Python
- python SyntaxError: invalid syntax %matplotlib inline
- Background color for Tk in Python
- If Python is interpreted, what are .pyc files?
- How to make a histogram from a list of data
- How do I change the figure size with subplots?
- ValueError: x and y must be the same size
- How do I get monitor resolution in Python?
- raise LinAlgError(“SVD did not converge”) LinAlgError: SVD did not converge in matplotlib pca determination
- TypeError: Invalid dimensions for image data when plotting array with imshow()
- matplotlib does not show my drawings although I call pyplot.show()
- Linear regression with matplotlib / numpy
- How to save a Seaborn plot into a file
- Scatter plot colorbar – Matplotlib
- What is runtime in context of Python? What does it consist of?
- matplotlib: how to draw a rectangle on image
- Unable to convert 3d ply file image to 2d image
- bbox_to_anchor and loc in matplotlib
- How can I set the ‘backend’ in matplotlib in Python?
- How to put the legend out of the plot
- Matplotlib: TypeError: can’t multiply sequence by non-int of type ‘numpy.float64’
- RuntimeError: Invalid DISPLAY variable
- How to plot an array in python?
- IndexError: index 2 is out of bounds for axis 0 with size 2
- Python High Pass Filter
- Why do many examples use `fig, ax = plt.subplots()` in Matplotlib/pyplot/python
- Where are the ampersand and vertical bar characters used in Python?
- Plot a histogram such that the total area of the histogram equals 1
- How to change legend size with matplotlib.pyplot
- An equivalent function to matplotlib.mlab.bivariate_normal
- plot a circle with pyplot
- Python: What OS am I running on?
- Plotting a python dict in order of key values
- Pandas dataframe groupby plot
- MovieWriter ffmpeg unavailable; trying to use class ‘matplotlib.animation.PillowWriter’ instead
- How to draw a line with matplotlib?
- How do I tell Matplotlib to create a second (new) plot, then later plot on the old one?
- Get all object attributes in Python?
- Equivalent to matlab’s imagesc in matplotlib? [duplicate]
- mport win32ui in python 3.6
- alueError: ordinal must be >= 1