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]
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- TypeError: only integer scalar arrays can be converted to a scalar index with 1D numpy indices array
- 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?
- Purpose of “%matplotlib inline”
- Purpose of “%matplotlib inline”
- 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()
- python – how to get the data from an plt.imshow()?
- ImportError: No module named matplotlib.pyplot
- 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
- RuntimeWarning: invalid value encountered in divide
- Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as plt”?
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- ValueError: operands could not be broadcast together with shapes (5,) (30,)
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- ImportError: No module named matplotlib.pyplot
- matplotlib savefig() plots different from show()
- “If not” condition statement in python
- syntaxerror: “unexpected character after line continuation character in python” math
- How can I sort a dictionary by key?
- How do I draw a grid onto a plot in Python?
- How do you do natural logs (e.g. “ln()”) with numpy in Python?
- 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
- No handles with labels found to put in legend
- 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]
- Unable to plot Double Bar, Bar plot using pyplot for ndarray
- matplotlib error – no module named tkinter
- pandas DataFrame “no numeric data to plot” error
- 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
- How do I use the yfinance API in Python to get today’s DJI open?
- what does the __file__ variable mean/do?
- How to change the font size on a matplotlib plot
- Permission denied error by installing matplotlib
- Updating matplotlib in virtualenv with pip
- How do you change the size of figures drawn with Matplotlib?
- How do I set the figure title and axes labels font size in Matplotlib?
- How to customize a scatter matrix to see all titles?
- Is there a list of line styles in matplotlib?
- Matplotlib automatic legend outside plot
- Add Legend to Seaborn point plot
- A tool to convert MATLAB code to Python
- 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
- Plotting multiple different plots in one figure using Seaborn
- Plot pie chart and table of pandas dataframe
- ModuleNotFoundError: No module named ‘matplotlib’
- Change figure size and figure format in 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
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- Improve subplot size/spacing with many subplots in matplotlib
- How do I plot only a table in Matplotlib?
- How do I correctly clean up a Python object?
- Python equivalent to ‘hold on’ in Matlab
- How to add title to subplots in Matplotlib
- Overcome ValueError for empty array
- How can I convert an RGB image into grayscale in Python?
- Implement touch using Python?
- Python setup.py develop vs install
- Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn’t work
- How to clamp an integer to some range?
- How to change a ‘LinearSegmentedColormap’ to a different distribution of color?
- Display image as grayscale using matplotlib
- Create own colormap using matplotlib and plot color scale
- Why matplotlib does not plot?
- How to plot time series in python
- reducing number of plot ticks
- 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
- Plot a horizontal line using matplotlib
- 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?
- How to add title to seaborn boxplot
- 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