File:Mpl example Rosenbrock function.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (SVG file, nominally 720 × 540 pixels, file size: 1.21 MB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
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

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
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.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current09:52, 27 September 2016Thumbnail for version as of 09:52, 27 September 2016720 × 540 (1.21 MB)Adrien F. Vincent (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file:

Metadata