![]() import re, seaborn as snsįrom lors import ListedColormapĪx = Axes3D(fig, auto_add_to_figure=False)Ĭmap = ListedColormap(sns.color_palette("husl", 256).as_hex()) ![]() Also, the output of ListedColorMap outputs a color map with transparency variations, so I had to manually set alpha to 1 in the scatter plot. Note that I generated more data points in order to better see that the colormap is the same. The result of the code is shown in the picture below. The color palette from Seaborn can be turned into a Matplotlib color map from an instance of a ListedColorMap class initialized with the list of colors in the Seaborn palette with the as_hex() method (as proposed in this original answer).įrom the Matplotlib documentation, you can generate a legend from a scatter plot with getting the handles and labels of the output of the scatter function. # ax = fig.add_subplot(111, projection='3d') # Method 2 Here's a MWE: import re, seaborn as sns, numpy as np, pandas as pd, randomįrom matplotlib.pyplot import plot, show, draw, figure, cm ![]() My references: How to make a 3D scatter plot in Python? warnings.warn("No labelled objects found. When I do plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.,ncol=4) I see the following error: anaconda2/lib/python2.7/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |