File:Mpl example polar plot.svg
Summary
Description |
English: Logarithmic spiral with matplotlib |
Date | |
Source | Own work |
Author | Adrien F. Vincent |
Rationale: this work aims at providing an up-to-date version of the previous work https://commons.wikimedia.org/wiki/File:Logarithmic_Spiral_Pylab.svg , done by Morn the Gorn.
The matplotlib (mpl) version is 1.5.3, with Python 2.7 and numpy 1.10
##########
## Code for the figure
##########
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import NullFormatter # empty strings as tick labels
# Set up a figure with a polar projection
fig = plt.figure(figsize=(6, 6))
fig.clf()
ax = fig.add_subplot(1, 1, 1, polar=True)
# Plot a logarithmic spiral
t = np.arange(-4 * np.pi, 4 * np.pi, 0.1)
ax.plot(t, 1.19**t, linewidth=2) # one could also use `plt.polar`
# One wants a grid but without any tick label
ax.xaxis.set_major_formatter(NullFormatter())
ax.yaxis.set_major_formatter(NullFormatter())
ax.grid(True, ls='solid', color='0.75')
fig.savefig('logarithmic_spiral.svg')
plt.show()
##########
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.