scipy.stats.probplot is a convenient function to plot QQ-plots. I want to visualize two classes of samples within one QQ-plot. Both classes should define one joint QQ-plot but I want the visualized dots to be different. According to the nice answer, https://stackoverflow.com/a/37463899/10844553 one can readily use the following code to adjust the style of all samples:
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
nsample = 100
np.random.seed(7654321)
fig = plt.figure()
ax = fig.add_subplot(111)
x = stats.t.rvs(3, size=nsample)
res = stats.probplot(x, plot=plt)
ax.get_lines()[0].set_marker('p')
ax.get_lines()[0].set_markerfacecolor('r')
ax.get_lines()[0].set_markersize(12.0)
ax.get_lines()[1].set_linewidth(12.0)
plt.show()
However, is there a way to adjust the style of samples that fulfill a specific condition? For instance all samples above some threshold? More precisely, in my case, each sample has a marker True/False, which decides over the style of the sample.
As an illustrative example, consider a data set that contains the average amount of cigarettes a person smokes. We can use the empirical data to generate a QQ-Plot. After that, I want to have 2 different styles of dot-representations: one style represents male smokers, the second represents female smokers.
It is important to note that plotting 2 separate QQ-plots within the same plot is not correct since this changes the order statistics and results in a QQ-plot that is different from the joint QQ-plot.