On Tue, May 28, 2013 at 3:50 AM, Nils Wagner <nils...@googlemail.com> wrote:

> Hi all,
>
> I would like to add a legend to a 3D plot.
> However, the legend ist not visible in the example given below.
> Am I missing something ?
>
> Nils
>
> import numpy as np
> from mpl_toolkits.mplot3d import Axes3D
> import matplotlib.pyplot as plt
> import random
>
> def fun(x, y):
>   return x**2 + y
> def fun1(x, y):
>   return 10+x**2 + y
>
> fig = plt.figure()
> ax = fig.add_subplot(111, projection='3d')
> x = y = np.arange(-3.0, 3.0, 0.05)
> X, Y = np.meshgrid(x, y)
> zs = np.array([fun(x,y) for x,y in zip(np.ravel(X), np.ravel(Y))])
> Z = zs.reshape(X.shape)
> zs = np.array([fun1(x,y) for x,y in zip(np.ravel(X), np.ravel(Y))])
> Z1 = zs.reshape(X.shape)
>
> ax.plot_surface(X, Y, Z, label=r'$f$')
> ax.plot_surface(X, Y, Z1,label=r'$f_1$')
>
> ax.set_xlabel('X Label')
> ax.set_ylabel('Y Label')
> ax.set_zlabel('Z Label')
> ax.legend()
> plt.show()
>
>
plot_surface() does not have any default representation in a legend.  I
have never thought about it before, but what would one want to display for
it?  It is kind of like wanting a legend entry for an imshow() or pcolor()
display.  If you have something in mind to display, I would suggest using
proxy artists.

Cheers!
Ben Root
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to