-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Seaborn scatter plot results in black and white dots (wrong color) #8913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I don't see seaborn listed in your environment. Perhaps you are pulling in
an older version installed elsewhere, and that is triggering the
color_cycle usage?
…On Wed, Jul 19, 2017 at 11:23 AM, drigoF ***@***.***> wrote:
By using pandas I try to visualize the selection *frame* I have got from
my data frame df here below. I can not understand why seaborn via
matplotlib displays strange colorful dots for the class *car*. In my
opinion this problem should be related to the bug 5377
<#5377>. If I remove this
class I get the same problem in another one. Do you know how I can fix it?
Apparently this issue occurs only on my laptop.
When I run this code on python I get the following message:
/usr/lib/python3/dist-packages/matplotlib/*init*.py:874: UserWarning:
axes.color_cycle is deprecated and replaced with axes.prop_cycle; please
use the latter.
warnings.warn(self.msg_depr % (key, alt_key))
For more details please have a look at this Page
<https://stackoverflow.com/questions/45127983/seaborn-scatter-plot-with-missing-points-in-the-figure>
I tried to use the following solutions but they did not give me the right
results.
- from matplotlib.colors import rgb2hex (as suggested in 5377 issue
but it did not work out)
- plt.rcParams['image.cmap'] = 'gray' (as suggested in 5377 issue but
it did not work out)
- plt.rc('lines', linewidth=4)
plt.rc('axes', prop_cycle=(cycler('color', ['r', 'g', 'b', 'y']) +
cycler('linestyle', ['-', '--', ':', '-.']))) (a suggested in link)
<https://matplotlib.org/examples/color/color_cycle_demo.html>
*Code for reproduction*
import pandas as pd
import numpy as np
import random
from cycler import cycler
from matplotlib import pyplot as plt
#from matplotlib.colors import rgb2hex
import seaborn as sns
np.random.seed(176)
random.seed(16)
df = pd.DataFrame({'class': random.sample(['living room','dining room','kitchen','car','bathroom','office']*10, k=25),
'Amount': np.random.sample(25)*100,
'Year': random.sample(list(range(2010,2018))*50, k=25),
'Month': random.sample(list(range(1,12))*100, k=25)})
frame = pd.pivot_table(df, index=['class','Year'], values=['Amount'], aggfunc=np.sum).reset_index()
print(frame)
yaplot=sns.lmplot(x='Year' , y='Amount', data=frame, hue='class',palette='Set1', fit_reg=False,size= 5, aspect=5/3, legend=False,legend_out=False,scatter_kws={'s': 70})
yaplot.ax.legend(loc=2)
sns.plt.ticklabel_format(style='plain', axis='x',useOffset=False)
plt.show()
Output of my ipython3:
In [1]: %run StackOverFlow-Answer-ScatterPlotwithFORFinal.py
/usr/lib/python3/dist-packages/matplotlib/__init__.py:874: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
warnings.warn(self.msg_depr % (key, alt_key))
class Year Amount
0 bathroom 2014 16.453632
1 bathroom 2015 40.407985
2 bathroom 2016 63.377911
3 bathroom 2017 98.786027
4 car 2010 22.252528
5 car 2012 127.597498
6 car 2015 93.694632
7 dining room 2010 54.077396
8 dining room 2011 15.844124
9 dining room 2012 36.273090
10 dining room 2014 27.156423
11 kitchen 2010 69.254971
12 kitchen 2013 88.100901
13 kitchen 2016 86.370960
14 kitchen 2017 95.764052
15 living room 2010 53.252083
16 living room 2011 94.708138
17 living room 2015 78.666517
18 living room 2016 21.260494
19 office 2012 35.743781
*pd.show_versions()*
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-83-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.20.3
pytest: None
pip: 8.1.1
setuptools: None
Cython: None
numpy: 1.13.1
scipy: 0.17.0
xarray: None
IPython: 2.4.1
sphinx: None
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.2.2
numexpr: 2.6.2
feather: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: 0.999
sqlalchemy: None
pymysql: None
p
8000
sycopg2: None
jinja2: 2.8
s3fs: None
pandas_gbq: None
pandas_datareader: None
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8913>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-JG2eaElD5AARmrRj6Iob8ck1nyWks5sPh6fgaJpZM4Oc47J>
.
|
I am checking... Thanks for now. Drigo |
perhaps your random data are running into this: mwaskom/seaborn#840 |
You are right I was running the code with a old version seaborn. I was sure I checked it was the newest one but I did not. Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
By using pandas I try to visualize the selection frame I have got from my data frame df here below. I can not understand why seaborn via matplotlib displays strange colorful dots for the class car. In my opinion this problem should be related to the bug 5377. If I remove this class I get the same problem in another one. Do you know how I can fix it? Apparently this issue occurs only on my laptop.
When I run this code on python I get the following message:
/usr/lib/python3/dist-packages/matplotlib/init.py:874: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
warnings.warn(self.msg_depr % (key, alt_key))
For more details please have a look at this Page
I tried to use the following solutions but they did not give me the right results.
plt.rc('axes', prop_cycle=(cycler('color', ['r', 'g', 'b', 'y']) +
cycler('linestyle', ['-', '--', ':', '-.']))) (a suggested in link)
Code for reproduction
Output of my ipython3:
pd.show_versions()
The text was updated successfully, but these errors were encountered: