Skip to content

Conversation

bf108
Copy link

@bf108 bf108 commented Apr 17, 2023

Barcode plot function added

Comment on lines +284 to +309
ax.set_yticks(yticks)
ax.set_yticklabels(labels)

#Remove grid from yaxis
ax.grid(which='major',axis='x')
ax.set_facecolor('white')

if x_axis_label is not None:
ax.set_xlabel(x_axis_label)

if x_range is not None:
ax.set_xlim(x_range)

#Ensure bars aren't thick on plot
if len(ax.patches) < 15:
ax.set_ylim(ax.get_ylim()[0], 15)

if title is not None:
ax.set_title(title)

if legend is True:
ax.legend(loc="lower right")

if show is True:
plt.show()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bf108 What do you think about removing all this? My philosophy with plotting functions has changed recently, and now I think they should be pretty minimal. In particular, I think this method should return the (fig,ax) pair it creates and then the user is free to modify it (e.g., with ax.set_title, ax.legend etc.) after it is constructed. They can also call plt.show() when they'd like, or save it directly from the ax object.

This would allow us to remove quite a bit from the function signature as well. We could then add documentation for how a user could modify the plot after its been created with this function, e.g. showing how to add and move a legend or a title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants