0

I am trying to build a plot using matplotlib.pyplot as plt.

For example plt.hist(df.amount, bins = 30)

But when I hit enter in the console it generates the graph.

I want to apply xlim, ylim and title functions of plt but can't do this.

Anyone familiar with this behavior? Should I change Spyder settings?

Same behavior with Seaborn package.

5
  • 1
    So you're using the internal ipython console? Does it show the figures in the actual console? If so, try typing %matplotlib or %matplotlib qt before doing plt.hist(df.amount, bins=30). Commented Mar 22, 2018 at 10:21
  • @FHTMitchell Yes it shows within the terminal in Spyder. Why it behave like this? Should I use another development environment? Commented Mar 22, 2018 at 11:23
  • @FHTMitchell Please post an answer so I can accept it. Commented Mar 22, 2018 at 13:35
  • 1
    Just press Ctrl+Enter instead of Enter to create a new line instead of executing. That way you can add more code to customize your plot. Commented Mar 22, 2018 at 13:55
  • @steves OK :) done Commented Mar 22, 2018 at 15:31

1 Answer 1

1

try typing %matplotlib or %matplotlib qt before doing plt.hist(df.amount, bins=30). This will switch the console out of "inline" mode.

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

1 Comment

There is an option to make this permanent: Tools > Preferences > IPython console > Graphics >Graphics backend. Choose "automatic" instead of "inline".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.