This might help you I have dataframe i want to draw a scattor plot by dividing plot in 2 regions in region one only plot f_x_f1 vs A_x_f1, and in region2 plot f_x_f2 vs A_x_f2 , Here, using matplotlib! code :
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
### making some sample data
df = pd.DataFrame({"f_x_f1": np.random.randint(1,100,100)
, "A_x_f1": np.random.randint(1,100,100)
, "f_x_f2": np.random.randint(1,100,100)
, "A_x_f2": np.random.randint(1,100,100) })
fig, ax = plt.subplots(nrows=1, ncols=2)
ax[0].scatter(df.f_x_f1,df.A_x_f1)
ax[0].set_title("f_x_f1 vs A_x_f1")
ax[1].scatter(df.f_x_f2,df.A_x_f2)
ax[1].set_title("f_x_f2 vs A_x_f2")
Share :

Is there a way to make matplotlib scatter plot marker or color according to a discrete variable in a different column?
By : Sami
Date : March 29 2020, 07:55 AM
Hope this helps What you're doing will almost work, but you have to pass color a vector of colors, not just a vector of variables. So you could do: code :
color = df.Group.map({dut_groups[0]: "r", dut_groups[1]: "b"})
plt.scatter(x, y, color=color)
import seaborn as sns
import pandas as pd
from numpy.random import randn
data = pd.DataFrame(dict(x=randn(40), y=randn(40), g=["a", "b"] * 20))
sns.lmplot("x", "y", hue="g", data=data, fit_reg=False)

How to plot a scatter plot using a pandas dataframe where the xaxis values are n minus 1 columns and the last column is
By : F Yudhi Lesmana
Date : March 29 2020, 07:55 AM
Does that help First, you should move the declaration of fig, axes outside the loop so you don't create a new figure for each column. Also, looping over for i,j in row, column: does not work and would create another loop within your loop over the columns, which you don't want. code :
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# make sample dataframe
dicts = {}
keys = range(12)
for i in keys:
dicts["x%s"%i] = list(np.random.randint(40, size=20))
dicts["y12"] = list(range(1,21))
df_sample = pd.DataFrame(dicts)
# function to plot your dataframe
def plot_df_scatter_columns(df):
fig, axes = plt.subplots(3,4, figsize = (12, 8))
# initialize i and j
i=0
j=0
# loop over df.iloc[:, :1] instead of df
# to leave out last column in loop
for z in df.iloc[:, :1]:
axes[i, j].scatter(df[z], df['y12'])
axes[i, j].set_title(z + 'vs. y12')
# calculate i and j on the fly during loop over df
j += 1
if j > 3:
j=0
i += 1
plt.show()
plot_df_scatter_columns(df_sample)

How to make a scatter plot with nonnumerical column?
By : user3087868
Date : March 29 2020, 07:55 AM
With these it helps y_range parameter fixed the issue for me. I found it at Handling Categorical Data. code :
p = figure(
y_range=df['b'], # <  what I added
title="Something great",
tools='save,pan,box_zoom,reset,wheel_zoom',
background_fill_color="#fafafa"
)

How to make a scatter plot with varying scatter size and color corresponding to a range of values from a dataframe?
By : user3367289
Date : March 29 2020, 07:55 AM
hope this fix your issue You could use pandas.cut to create a couple of helper columns in df based on your color and size mappings. This should make it easier to pass these arguments to pyplot.scatter. N.B. It's worth noting that the values you've chosen for size may not distinguish the markers very well in the plot  it'd be worth experimenting with different sizes until you get the desired results code :
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df['color'] = pd.cut(df['Depth'], bins=[np.inf, 30, 40, 60, np.inf], labels=['red', 'blue', 'black', 'yellow'])
df['size'] = pd.cut(df['Magnitude'], bins=[np.inf, 2, 3, 4, np.inf], labels=[1, 1.5, 2, 2.5])
plt.scatter(df['Lon'], df['Lat'], c=df['color'], s=df['size'])
def magnitude_size(magnitude):
if magnitude < 2 :
return 1
if magnitude >= 2 and magnitude < 3 :
return 1.5
if magnitude >= 3 and magnitude < 4 :
return 2
if magnitude >= 4 :
return 2.5
def depth_color(depth):
if depth < 30 :
return 'red'
if depth >= 30 and depth < 40 :
return 'blue'
if depth >= 40 and depth < 60 :
return 'black'
if depth >= 60 :
return 'yellow'
if np.isnan(depth):
return 'green'
di = {
'size': df.Magnitude.apply(magnitude_size),
'color' : df.Depth.apply(depth_color)
}
plt.scatter(df.Lon,df.Lat,c=di['color'],s=di['size'])

Excel  How can I make a scatter plot which colors by a third column?
By : Madhur Chauhan
Date : March 29 2020, 07:55 AM
this will help This is the best (nonvba) way I can think of to go about this (I'd recommend VBA if you know the language), but it may involve too much manual work depending on how many types you really have. To start, flip the Y and X columns, and add a new column for each datatype you have (see image below)

