Created
September 5, 2018 12:08
-
-
Save ven-kyoshiro/331c9239d1e69ee7963e3f6b2564e42e to your computer and use it in GitHub Desktop.
openai gym's render cannot work with matplotlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib | |
# matplotlib.use("TkAgg") | |
import matplotlib.pyplot as plt | |
import gym | |
import numpy as np | |
def main(): | |
env = gym.make('CartPole-v0') | |
env.reset() | |
_ = env.render(mode='rgb_array') | |
left = np.array([1, 2, 3, 4, 5]) | |
height = np.array([100, 300, 200, 500, 400]) | |
plt.plot(left, height) | |
if __name__ == '__main__': | |
main() |
Author
ven-kyoshiro
commented
Sep 5, 2018
This is the answer !!!!!!!!!!
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
import gym
import numpy as np
def main():
env = gym.make('CartPole-v0')
env.reset()
_ = env.render(mode='rgb_array')
env.close()
left = np.array([1, 2, 3, 4, 5])
height = np.array([100, 300, 200, 500, 400])
plt.plot(left, height)
if __name__ == '__main__':
main()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment