1

I have >1 million data points so I utilize the alpha when plotting.

# set up axes
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(121)
ax3 = fig.add_subplot(122, sharey = ax1)

# two y-axis
ax2 = ax1.twiny()

# invert y-axis
ax1.invert_yaxis()

# plotting
p1 = ax1.plot(kh['TORQUE.AVG'], kh['DEPTH'], label = 'Torque (kft-lb)', color = 'green', marker = '.', alpha = 1/60)
p2 = ax2.plot(kh['ROP.AVG'], kh['DEPTH'], label = 'ROP (ft/hr)', color = 'black', marker = '.', alpha = 1/60)
p3 = ax3.plot(kh['WOB.AVG'], kh['DEPTH'], label = 'WOB (klb)', color = 'red', marker = '.', alpha = 1/60)

Now when I have two lines that shares the same plot, I wrote the following code to include both lines in one legend.

# legend
p_total = p1 + p2
legends = [i.get_label() for i in p_total]
ax1.legend(p_total, legends)
ax3.legend()

However, because I used alpha now my legend is affected and I essentially cannot see my legend.

enter image description here

Andrea
  • 2,932
  • 11
  • 23
SimplyLucKey
  • 29
  • 1
  • 3
  • Do you really need to use a scatterplot? I believe that even using alpha it can generate misleading plots. I would try some alternatives like [hist2d](https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.hist2d.html), or [hexbin plot](https://seaborn.pydata.org/examples/hexbin_marginals.html) or [kde plot](https://seaborn.pydata.org/examples/multiple_joint_kde.html) – Andrea Jan 07 '20 at 09:18
  • @Andrea For now yes. But I will look into those alternative plots – SimplyLucKey Jan 09 '20 at 00:00

0 Answers0