Skip to content
Snippets Groups Projects
Commit 53ef7f2f authored by Erik Strand's avatar Erik Strand
Browse files

Make plots a little more readable

parent c6591c89
Branches
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ class OffsetLogNorm(mpl.colors.Normalize):
def rosenbrock_plot(x_min, x_max, y_min, y_max):
fig = plt.figure(figsize=(8,7))
left, bottom, width, height = 0.1, 0.1, 0.8, 0.8
left, bottom, width, height = 0.1, 0.1, 0.86, 0.8
ax = fig.add_axes([left, bottom, width, height])
ax.set_aspect(1)
#ax.set_xlabel('x (cm)')
......@@ -33,7 +33,7 @@ def rosenbrock_plot(x_min, x_max, y_min, y_max):
Z = rosenbrock(X, Y)
levels = [1e-2, 1e-1, 1e0, 1e1, 1e2, 1e3, 1e4, 1e5]
ax.contour(X, Y, Z, levels, colors='k')
ax.contour(X, Y, Z, levels, colors='0.5', linewidths=0.5)
contour_filled = ax.contourf(X, Y, Z, levels,
cmap='plasma',
norm=OffsetLogNorm(vmin=Z.min(), vmax=Z.max(), offset = 1)
......@@ -45,13 +45,13 @@ def rosenbrock_plot(x_min, x_max, y_min, y_max):
def add_points(fig, ax, points):
x = [p[0] for p in points]
y = [p[1] for p in points]
ax.plot(x, y, 'bx')
ax.plot(x, y, 'k.')
return fig, ax
# points is a list of numpy arrays of dim n x 2
def add_polygons(fig, ax, polygons):
for polygon in polygons:
p = mpl.patches.Polygon(polygon, True, fill=False, color="black")
p = mpl.patches.Polygon(polygon, True, fill=False, color="black", zorder=2)
ax.add_patch(p)
#p = PatchCollection(patches, alpha=0.4)
#ax.add_collection(p)
......@@ -90,7 +90,7 @@ if __name__ == "__main__":
data = vis_json["data"]
if objective == "rosenbrock":
fig, ax = rosenbrock_plot(-3, 3, -3, 3)
fig, ax = rosenbrock_plot(-2.5, 2.5, -2.5, 2.5)
# need to implement this
#elif objective == "paraboloid":
# fig, ax = paraboloid_plot(-3, 3, -3, 3)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment