I’m very new with these libraries and i’m having troubles while plotting this:
JavaScript
x
12
12
1
import pandas as pd
2
import seaborn as sns
3
import matplotlib.pyplot as plt
4
import numpy as np
5
import random
6
7
df5 = pd.read_csv('../../../../datos/tiempos-exacto-variando-n-m0.csv', sep=', ', engine='python')
8
print(df5)
9
df5['n'] = df5['n'].apply(lambda x: x**2)
10
sns.jointplot(df5['n'], df5['tiempoTotal'], kind="reg")
11
sns.plt.show()
12
And i’m getting this output:
JavaScript
1
73
73
1
n m tiempoTotal
2
0 1 0 2274
3
1 2 0 3370
4
2 3 0 5709
5
3 4 0 8959
6
4 5 0 13354
7
5 6 0 18503
8
6 7 0 26329
9
7 8 0 33859
10
8 9 0 41110
11
9 10 0 52710
12
10 11 0 64364
13
11 12 0 74142
14
12 13 0 81072
15
13 14 0 69332
16
14 15 0 71027
17
15 16 0 89721
18
16 17 0 85459
19
17 18 0 95217
20
18 19 0 119210
21
19 20 0 136888
22
20 21 0 131903
23
21 22 0 138395
24
22 23 0 151222
25
23 24 0 163542
26
24 25 0 177236
27
25 26 0 192475
28
26 27 0 240162
29
27 28 0 260701
30
28 29 0 235752
31
29 30 0 250835
32
.. ..
33
580 581 0 88306854
34
581 582 0 89276420
35
582 583 0 87457875
36
583 584 0 90807004
37
584 585 0 87790003
38
585 586 0 89821530
39
586 587 0 89486585
40
587 588 0 88496901
41
588 589 0 89090661
42
589 590 0 89110803
43
590 591 0 90397942
44
591 592 0 94029839
45
592 593 0 92749859
46
593 594 0 105991135
47
594 595 0 95383921
48
595 596 0 105155207
49
596 597 0 114193414
50
597 598 0 98108892
51
598 599 0 97888966
52
599 600 0 103802453
53
600 601 0 97249346
54
601 602 0 101917488
55
602 603 0 104943847
56
603 604 0 98966140
57
604 605 0 97924262
58
605 606 0 97379587
59
606 607 0 97518808
60
607 608 0 99839892
61
608 609 0 100046492
62
609 610 0 103857464
63
64
[610 rows x 3 columns]
65
---------------------------------------------------------------------------
66
AttributeError Traceback (most recent call last)
67
<ipython-input-21-63146953b89d> in <module>()
68
9 df5['n'] = df5['n'].apply(lambda x: x**2)
69
10 sns.jointplot(df5['n'], df5['tiempoTotal'], kind="reg")
70
---> 11 sns.plt.show()
71
72
AttributeError: 'module' object has no attribute 'plt'
73
I’m running this in my Jupyter Notebook
with Python 2.7.12
. Any ideas?
Advertisement
Answer
sns.plt.show()
works fine for me using seaborn 0.7.1. Could be that this is different in other versions. However, if you anyways import matplotlib.pyplot as plt
you may as well simply use plt.show()
, as sns.plt.show()
is only working because pyplot
is available inside the seaborn namespace.