0

I have a multipanel plot of the following:

fig, axs = plt.subplots(1, 2, sharey=True, figsize = (20 , 10) , gridspec_kw={'hspace': 0, 'wspace': 0})

axs[0].scatter(fullmergedf['gf_re_j'] , fullmergedf['PAB_SFR_EX2'] , s = 200)
axs[0].scatter(fullmergedf['gf_re_j'] , fullmergedf['PAB_SFR_EX2_LL'] , s = 200 , marker = '+' , c = 'black')
axs[0].plot([0 , 2] , [0 , 0] , '--' , c = 'gray')
axs[0].set_ylabel(r'log($SFR_{Pa\beta}$) - log($SFR_{UV}^{corr}$)')
axs[0].set_xlabel(r"$R_{eff}$ [arcsec]")
axs[0].axis([0 , 1.7 , -2.5 , 3])

axs[1].scatter(fullmergedf['gf_n_j'] , fullmergedf['PAB_SFR_EX2'] , s = 200)
axs[1].scatter(fullmergedf['gf_n_j'] , fullmergedf['PAB_SFR_EX2_LL'] , s = 200 , marker = '+' , c = 'black')
axs[1].plot([0 , 8] , [0 , 0] , '--' , c = 'gray')
axs[1].set_xlabel(r"n")
axs[1].axis([0 , 3 , -2.5 , 3])
#axs[1].set_xscale('log')

plt.show()

I would like to remove some of the points in this scatter plot using a condition from another column in the dataframe. The condition needs to be that only points where fullmergedf['gf_f_j'] is 0 for that object. Is there an efficient method in pandas to do something like this?

2
  • 1
    Can you do a boolean slice? So maybe x = fullmergedf['gf_re_j'][fullmergedf['gf_re_j'] == 0] and y = fullmergedf['PAB_SFR_EX2'][fullmergedf['gf_re_j'] == 0], then ax.scatter(x,y) (just breaking out to variables for readability). Commented Jun 2, 2020 at 23:54
  • @Tom this worked, thank you. This is the nice, simple solution I was looking for. Commented Jun 3, 2020 at 16:42

1 Answer 1

1

Can you do a boolean slice? So maybe x = fullmergedf['gf_re_j'][fullmergedf['gf_re_j'] == 0] and y = fullmergedf['PAB_SFR_EX2'][fullmergedf['gf_re_j'] == 0], then ax.scatter(x,y) (just breaking out to variables for readability).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.