File:Mpl_screenshot_figures_and_code.png
From Wikipedia, the free encyclopedia
Size of this preview: 752 × 599 pixels. Other resolutions: 301 × 240 pixels | 602 × 480 pixels | 964 × 768 pixels | 1,227 × 978 pixels.
Original file (1,227 × 978 pixels, file size: 350 KB, MIME type: image/png)
This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
Summary
DescriptionMpl screenshot figures and code.png |
English: A screenshot showing matplotlib plots of a polar bar graph resembling the matplotlib logo (upper left), a 3D surface graph with the new default 'viridis' colormap (lower left), a graph of 2D random walk trajectories (lower right), and the python source code (of the logo part) opened in a text editor (upper right). |
Date | |
Source | Own work |
Author | Adrien F. Vincent |
Rationale: this work aims at providing an up-to-date version of the previous work https://en.wikipedia.org/wiki/File:Matplotlib_screenshot.png , done by Geek3.
The matplotlib (mpl) version is the development branch 2.x, with Python 2.7.11 and numpy 1.11.1
##########
## Code for the mpl logo figure
##########
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.cm import jet as colormap
from matplotlib.ticker import NullFormatter, MultipleLocator
t, w, r = zip((0.1, 0.4, 1), (0.9, 0.3, 5), (1.7, 0.5, 7), (2.7, 0.6, 6),
(3.5, 0.3, 3), (4.5, 0.4, 4), (5.3, 0.3, 7))
fig, ax = plt.subplots(subplot_kw={'polar': True})
bars = ax.bar(t, r, width=w, bottom=0.0, lw=2, edgecolor='Black', zorder=2)
for r, bar in zip(r, bars):
bar.set_facecolor(colormap(r / 9.0))
bar.set_alpha(0.7)
ax.yaxis.set_major_locator(MultipleLocator(2))
for axis in (ax.xaxis, ax.yaxis):
axis.set_major_formatter(NullFormatter()) # no tick labels
ax.set_ylim([0, 8])
ax.grid(True)
plt.show()
####################
##########
## Code for the 3D surface plot and the 2D random walk tajectories
##########
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.cm import viridis as colormap
"""
Figure 1: a 3D surface plot (from matplotlib gallery)
"""
step = 0.04
maxval = 1.0
fig1 = plt.figure("Figure_1")
ax1 = fig1.add_subplot(111, projection='3d')
# Create supporting points in polar coordinates
r = np.linspace(0, 1.2, 50)
p = np.linspace(0, 2*np.pi, 50)
R, P = np.meshgrid(r, p)
# Transform them to cartesian system
X, Y = R*np.cos(P), R*np.sin(P)
Z = ((R**2 - 1)**2)
ax1.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=colormap)
ax1.set_zlim3d(0, 1)
ax1.set_xlabel(r'$\phi_\mathrm{real}$')
ax1.set_ylabel(r'$\phi_\mathrm{im}$')
ax1.set_zlabel(r'$V(\phi)$')
"""
Figure 2: a few examples of 2D random walk
"""
fig2, ax2 = plt.subplots(num="Figure_2")
prng = np.random.RandomState(123)
x = np.linspace(0, 10, 101)
def random_walk(xy0=(0.0, 0.0), nsteps=100, std=1.0):
xy = np.zeros((nsteps + 1, 2))
xy[0,:] = xy0
deltas = prng.normal(loc=0.0, scale=std, size=(nsteps, 2))
xy[1:, :] = xy[0, :] + np.cumsum(deltas, axis=0)
return xy
for cnt in range(3):
traj = random_walk()
ax2.plot(traj[:, 0], traj[:, 1], label="Traj. {c}".format(c=cnt))
ax2.legend(loc='best')
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.
Items portrayed in this file
depicts
26 September 2016
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 09:52, 27 September 2016 | 1,227 × 978 (350 KB) | Adrien F. Vincent | User created page with UploadWizard |
File usage
The following pages on the English Wikipedia use this file (pages on other projects are not listed):
Global file usage
The following other wikis use this file:
- Usage on bn.wikipedia.org
- Usage on fr.wikipedia.org
- Usage on hu.wikipedia.org
- Usage on ja.wikipedia.org
- Usage on ko.wikipedia.org
- Usage on pl.wikipedia.org
- Usage on pt.wikipedia.org
- Usage on sr.wikipedia.org
- Usage on tr.wikipedia.org
- Usage on zh.wikipedia.org
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
Horizontal resolution | 28.35 dpc |
---|---|
Vertical resolution | 28.35 dpc |
File change date and time | 12:58, 26 September 2016 |