I’m currently making a plot in Python using plotnine, and wanted to add text labels to it. To avoid too much overlapping, I decided to use adjust_text
alongside geom_text
. However, adjust_text
does not work, and the program is unable to compile.
I first saw this thread, which advised me to include a dictionary and install the adjustText package. Upon doing both, however, I now get this error:
AttributeError: FancyArrowPatch.set() got an unexpected keyword argument 'expand_points'
My relevant code is as follows:
adjust_text_dict = {
'expand_points': (2,2),
'arrowprops': {
'arrowstyle': '-',
'color': 'black'
}
}
plot = (p9.ggplot(quarcs_wr, p9.aes("preanx11", "prepcttotal", label = 'instructor_name')) +
p9.geom_point(shape = "D", color = "#666799", fill = "#4f82be", size = 4) +
p9.ggtitle('Mean QuaRCS Pre-Score vs. Mean Anxiety (Measure 1) by Instructor') +
p9.xlab("Mean Anxiety (Measure 1)") +
p9.ylab("Percent of Questions Answered Correctly") +
p9.geom_smooth(method = 'lm', se = False) +
p9.geom_label(adjust_text = adjust_text_dict)
)
user25670083 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.