2

So I'm using yellowbrick in Python, which is basically matplotlib and scikit-learn combined, to visualize some data.

My chart looks like this:

enter image description here

The labels get cut off. What I want to do is to adjust the figure so the labels on the right don't get cut off. I tried

plt.rcParams['figure.figsize'] = (10, 5)
plt.rcParams['font.size'] = 12

but when I rendered the figure, it's still cut off. Even when I save it as a png file it's still cut off. What am I missing here?

0

1 Answer 1

1

tight_layout method should solve your problem. Generally you can use it with:

fig.tight_layout()  # if fig is your figure handle

or

plt.tight_layout()  # if stated within the context of your figure

This line of code should be added after the last plotting statement just before rendering the figure.

If this does not work, please post a fully working minimal code example, as described in mcve. Afterwards I'll be able to post a fully working solution for most, if not all, cases.

Sign up to request clarification or add additional context in comments.

2 Comments

ok it worked after you said that part where it should be added just before plotting the figure. thanks!
You are welcome and may also upvote my answer. Yeah, if you add it before plotting the lines/scatter etc., the plot will be resized automatically and lose the tight layout. Thus you have to add it after all changes to the plot, like scaling etc., have been made.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.