File:Mpl example Rosenbrock function.svg
Summary
| Description |
English: Rosenbrock function over , plotted with matplotlib (and with "inferno", a perceptually monotonic colormap). |
| Date | |
| Source | Own work |
| Author | Adrien F. Vincent |
| SVG development |
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.
Source code

This media was created with Matplotlib (comprehensive library for creating static, animated, and interactive visualizations in Python)Category:Images with Matplotlib source code and Python (general-purpose programming language)Category:Images with Python source code and NumPy (numerical programming package for the Python programming language)Category:Images with NumPy source code
Here is a listing of the source used to create this file.
Here is a listing of the source used to create this file.
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.