Mpl_example_Rosenbrock_function.svg
Size of this PNG preview of this SVG file:
720 × 540 pixels
.
Other resolutions:
320 × 240 pixels
|
640 × 480 pixels
|
1,024 × 768 pixels
|
1,280 × 960 pixels
|
2,560 × 1,920 pixels
.
Summary
Description Mpl example Rosenbrock function.svg |
English:
Rosenbrock function over
, plotted with matplotlib (and with "inferno", a perceptually monotonic colormap).
|
Date | |
Source | Own work |
Author | Adrien F. Vincent |
Rationale: this work aims at providing an up-to-date version of the similar work https://commons.wikimedia.org/wiki/File:Rosenbrock_function.svg , done by Morn the Gorn.
Source code has been slightly modified into fully object-oriented matplotlib interface. It now uses the "inferno" colormap, instead of "jet" which produces perceptual glitches.
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 mpl_toolkits.mplot3d import Axes3D
from matplotlib.cm import inferno as colormap
from matplotlib.colors import LogNorm
fig = plt.figure()
fig.clf()
ax = Axes3D(fig, azim=-128.0, elev=43.0)
s = 0.05
x = np.arange(-2.0, 2.0 + s, s)
y = np.arange(-1.0, 3.0 + s, s)
X, Y = np.meshgrid(x, y)
Z = (1.0 - X)**2 + 100.0 * (Y - X*X)**2
# Without using `` linewidth=0, edgecolor='none' '', the code may produce a
# graph with wide black edges, which will make the surface look much darker.
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, norm=LogNorm(),
cmap=colormap, linewidth=0, edgecolor='none')
ax.set_xlim([-2, 2])
ax.set_ylim([-1, 3])
ax.set_zlim([0, 2500])
ax.set_xlabel("x")
ax.set_ylabel("y")
fig.savefig("Rosenbrock function.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.