Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved axis label rotation #872

Merged
merged 1 commit into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/sources/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ The CHANGELOG for the current development version is available at

- Due to compatibility issues with newer package versions, certain functions from six.py have been removed so that mlxtend may not work anymore with Python 2.7.
- As an internal change to speed up unit testing, unit testing is now faciliated by GitHub workflows, and Travis CI and Appveyor hooks have been removed.
- Improved axis label rotation in `mlxtend.plotting.heatmap` and `mlxtend.plotting.plot_confusion_matrix` ([#872](https://github.com/rasbt/mlxtend/pull/872))

##### Bug Fixes

- Fix unreadable labels in `heatmap` for certain colormaps. ([#852](https://github.com/rasbt/mlxtend/pull/852))
Expand Down
6 changes: 3 additions & 3 deletions docs/sources/user_guide/plotting/heatmap.ipynb

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/sources/user_guide/plotting/plot_confusion_matrix.ipynb

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion mlxtend/plotting/heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ def heatmap(matrix,

if column_names is not None:
tick_marks = np.arange(len(column_names))
plt.xticks(tick_marks, column_names, rotation=column_name_rotation)

if column_name_rotation:
plt.xticks(tick_marks, column_names, rotation=column_name_rotation,
ha="right", rotation_mode="anchor")
else:
plt.xticks(tick_marks, column_names)

if hide_spines:
ax.spines['right'].set_visible(False)
Expand Down
3 changes: 2 additions & 1 deletion mlxtend/plotting/plot_confusion_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def plot_confusion_matrix(conf_mat,
> np.max(conf_mat) * fontcolor_threshold else "black")
if class_names is not None:
tick_marks = np.arange(len(class_names))
plt.xticks(tick_marks, class_names, rotation=45)
plt.xticks(tick_marks, class_names, rotation=45,
ha="right", rotation_mode="anchor")
plt.yticks(tick_marks, class_names)

if hide_spines:
Expand Down