File:Rosenbrock3.gif
From Wikimedia Commons, the free media repository
Jump to navigation
Jump to search
Rosenbrock3.gif (600 × 400 pixels, file size: 1.14 MB, MIME type: image/gif, looped, 41 frames, 8.2 s)
File information
Structured data
Captions
Summary
[edit]DescriptionRosenbrock3.gif |
English: Animation of Rosenbrock's function of three variables. |
Date | |
Source | Own work |
Author | nicoguaro |
GIF development InfoField | This plot was created with Matplotlib. |
Source code InfoField | Python code"""
Animation of the Rosenbrock function of three variables
"""
import numpy as np
from scipy.optimize import rosen
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.animation as animation
Axes3D
plt.rcParams["font.size"] = 10
plt.rcParams["mathtext.fontset"] = "cm"
x1, x2 = np.mgrid[-2.5:2.5:51j, -2.5:2.5:51j]
x3 = np.linspace(-2.5, 2.5, 21)
x3 = np.append(x3, x3[-2::-1])
fun = rosen([x1, x2, x3[0]])
fig = plt.figure(figsize=(6, 4))
ax = fig.add_subplot(111, projection='3d')
ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
ax.w_zaxis.set_pane_color((1.0, 1.0, 1.0, 0.0))
def data_gen(num):
fun = rosen([x1, x2, x3[num]])
ax.cla()
surf = ax.plot_wireframe(x1, x2, fun/1000, linewidth=1, color="#3c3c3c",
rstride=51, cstride=51)
contour = ax.contour(x1, x2, fun/1000, 20)
ax.set_xlabel(r"$x_1$", fontsize=12)
ax.set_ylabel(r"$x_2$", fontsize=12)
ax.set_zlabel(r"$f(x_1, x_2, x_3)/10^3$", fontsize=12)
ax.set_title(r"$x_3 = {}$".format(x3[num]), fontsize=12, y=1.08)
ax.set_xlim(-2.5, 2.5)
ax.set_ylim(-2.5, 2.5)
ax.set_zlim(0, 16)
ax.view_init(elev=45, azim=-45)
return surf, contour
ani = animation.FuncAnimation(fig, data_gen, range(41))
ani.save("rosenbrock3.gif", writer='imagemagick')
plt.show()
|
Licensing
[edit]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.
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 17:24, 26 June 2018 | 600 × 400 (1.14 MB) | Nicoguaro (talk | contribs) | Improve lines width | |
23:36, 9 December 2017 | 840 × 600 (255 KB) | Pasimi (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on en.wikipedia.org
- Usage on uk.wikipedia.org