Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using code from a book that's meant to display a very simple visualization using the matplotlib python 2D plotting library, and I've tried modifying it to work on c9 with no success so far. Here's where I'm at now:

import os
import matplotlib
# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt

squares = [1, 4, 9, 16, 25]
plt.plot(squares)
#plt.show()

#Cloud9 env
if __name__ == '__main__':
    plt.show(host=os.getenv('IP', '0.0.0.0'),port=int(os.getenv('PORT', 8080)), debug=True)

...which gives this message in the Run panel:

Your code is running at https://node-01-vdesr.c9users.io.
Important: use os.getenv(PORT, 8080) as the port and os.getenv(IP, 0.0.0.0) as the host in your scripts!

Process exited with code: 0


Nothing shows in the URL though. Here's the original code (much shorter) that I started with:

import matplotlib.pyplot as plt

squares = [1, 4, 9, 16, 25]
plt.plot(squares)
plt.show()


What I have tried:

credit original Post: How can I get this code to work on c9? - Cloud9 Support - Cloud9 Community[^]
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900