Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help needed for Matplotlib in Stata

    Hi,

    I am using Stata 17 and was using some python codes to plot some bar charts. Below is my code:

    Code:
    python:
    import os
    os.chdir("C:/Users/ngwee/OneDrive/INSEAD RA work")
    import pandas as pd
    df = pd.read_csv('start_date.csv')
    import matplotlib.pyplot as plt
    x = df['rec_start_dates']
    y = df['unrate_rec_start']
    plt.bar(x,y)
    plt.ylabel('Monthly Unemployment Rate(seasonally adjusted)')
    plt.xlabel('Months')
    plt.title("Unemployment at Recession Start dates")
    plt.bar(x, y, color='blue')
    plt.savefig("myplot.png")
    plt.show()
    end
    However, when I run the codes, I am greeted with an error message:

    Code:
    ---------------------------
    StataSE-64
    ---------------------------
    This application failed to start because it could not find or load the Qt platform plugin "windows"
    in "".
    
    Reinstalling the application may fix this problem.
    ---------------------------
    OK   
    ---------------------------
    May I know what do I have to install in Stata to make Matplotlib work? I had run other codes except for Matplotlib and they run smoothly so I am not sure how to make it work.

    Any help in this area would be appreciated. Thanks!




    Attached Files

  • #2
    I don't know but the Stata version of the problem would seem to yield to twoway bar quite easily.

    Comment


    • #3
      This is probably a python issue: to side-step the problem try using a different backend for matplotlib adding
      Code:
      matplotlib.use('TKAgg')
      after import matplotlib. If you need Qt you may have to reinstall packages - google the error message and you will find suggestions.

      Comment

      Working...
      X