File:Himmelblau contour.svg

Summary

Description
English: Log-spaced down contour plot of Himmelblau's function.
Date
Source Own work
Author Nicoguaro
SVG development
InfoField
Source code
InfoField

Python code

"""
Contour plot of the Himmelblau function.
"""
from __future__ import division
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rcParams

rcParams['font.size'] = 12

npts = 201
x, y = np.mgrid[-6:6:npts*1j, -6:6:npts*1j]
z = (x**2 + y - 11)**2 + (x + y**2 - 7)**2

fig = plt.figure(figsize=(5, 5))
levels = np.logspace(0.3, 3.5, 15)
plt.contour(x, y, z, levels, cmap="viridis")
plt.xlabel(r"$x$", fontsize=14)
plt.ylabel(r"$y$", fontsize=14)
plt.xticks([-6, -3, 0, 3, 6])
plt.yticks([-6, -3, 0, 3, 6])
plt.xlim([-6, 6])
plt.ylim([-6, 6])
plt.savefig("Himmelblau_contour.svg", bbox_inches="tight")
plt.show()

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution
This file is licensed under the Creative Commons Attribution 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.
Category:CC-BY-4.0#Himmelblau%20contour.svgCategory:Self-published work
Category:Contour plots Category:Himmelblau's function
Category:CC-BY-4.0 Category:Contour plots Category:Himmelblau's function Category:Self-published work Category:Valid SVG created with Matplotlib code