Plotting multiple pandas scatter plots

I think there are many questions about plotting multiple charts, but not specifically for this case, as shown below.

The documentation for pandas says "repeat the graphing method" to build several groups of columns on the same axis. However, how will this work for 3 or more column groups? For example, if we define a third column:

bx = df.plot(kind='scatter', x='a',y='f',color = 'Green',label ='f')

Where will this bx go?

Also, if the graph is the same graph, should the x axis not be sequentially “a” or “c”? but the documentation has two different x axes: 'a' and 'c'

enter image description here

+8
3

bx ?

plot, , bx.

: plot ax. , . , . , , . , ax plot .

, , :

import pandas as pd
import numpy as np

df = pd.DataFrame(np.random.randn(100, 6), columns=['a', 'b', 'c', 'd', 'e', 'f'])


ax1 = df.plot(kind='scatter', x='a', y='b', color='r')    
ax2 = df.plot(kind='scatter', x='c', y='d', color='g', ax=ax1)    
ax3 = df.plot(kind='scatter', x='e', y='f', color='b', ax=ax1)

print(ax1 == ax2 == ax3)  # True

enter image description here

, , x "a", "c"?

. , , . , a , c - , "" . , a c , , , .

+10

, . , . . , , , , , , , .

, (ax), ax, . , .

ax = df.plot(kind="scatter", x="x",y="a", color="b", label="a vs. x")
df.plot(x="x",y="b", color="r", label="b vs. x", ax=ax)
df.plot( x="x",y="c", color="g", label="c vs. x", ax=ax)

:

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0,6.3, 50)
a = (np.sin(x)+1)*3
b = (np.cos(x)+1)*3
c = np.ones_like(x)*3
d = np.exp(x)/100.
df = pd.DataFrame({"x":x, "a":a, "b":b, "c":c, "d":d})

ax = df.plot(kind="scatter", x="x",y="a", color="b", label="a vs. x")
df.plot(x="x",y="b", color="r", label="b vs. x", ax=ax)
df.plot( x="x",y="c", color="g", label="c vs. x", ax=ax)
df.plot( x="d",y="x", color="orange", label="b vs. d", ax=ax)
df.plot( x="a",y="x", color="purple", label="x vs. a", ax=ax)

ax.set_xlabel("horizontal label")
ax.set_ylabel("vertical label")
plt.show()

enter image description here

+6

Inside the pyviz verse there is a library called hvplotthat provides a very good high-level charting function (on top holoviews) that works with panda boxes:

import numpy as np
import hvplot.pandas

df = pd.DataFrame(np.random.randn(100, 6), columns=['a', 'b', 'c', 'd', 'e', 'f'])

df.hvplot(x='a', y=['b', 'c', 'd', 'e'], kind='scatter')

enter image description here

0
source

Source: https://habr.com/ru/post/1673378/


All Articles