Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Risk plot_board Not Plotting #525

Open
pulsar-heart opened this issue Apr 15, 2023 · 1 comment
Open

Risk plot_board Not Plotting #525

pulsar-heart opened this issue Apr 15, 2023 · 1 comment

Comments

@pulsar-heart
Copy link

I want to plot the risk boards given in test_search.py. I decided to start by trying to plot one using the plot_board function. Here is my code:

  1 from risk.board import *
  2 #import matplotlib.pyplot as plt
  3 #import matplotlib.patches as patches
  4 #from matplotlib.path import Path
  5 import copy
  6 
  7 board0 = Board([Territory(territory_id=i, player_id=1, armies=i%5+1) for i in range(42)])
  8 
  9 board1 = copy.deepcopy(board0)
 10 board1.set_owner(3,0)
 11 board1.set_armies(3,500)
 12 board1.set_armies(4,500)
 13 board1.set_armies(34,500)
 14 board1.set_armies(39,500)
 15 board1.set_armies(35,500)
 16 
 17 board2 = copy.deepcopy(board1)
 18 board2.set_owner(34, 0)
 19 board2.set_armies(34,1)
 20 board2.set_owner(35, 0)
 21 board2.set_armies(35,1)
 22 board2.set_owner(39, 0)
 23 board2.set_armies(39,1)
 24 
 25 board3 = copy.deepcopy(board2)
 26 board3.set_owner(34, 1)
 27 
 28 board4 = copy.deepcopy(board2)
 29 board4.set_owner(4, 0)
 30 board4.set_armies(4, 1)
 31 board4.set_owner(1, 0)
 32 
 33 board5 = Board([Territory(territory_id=i, player_id=i%5, armies=i%5+1) for i in range(42)])
 34 
 35 board5.plot_board(path=None, plot_graph = False, filename = plot)

When I attempt to run this file, I get the following error:

Traceback (most recent call last):
  File "debug.py", line 35, in <module>
    board5.plot_board(path=None, plot_graph = False)
  File "/home/ksmith3987/proj/risk/risk/board.py", line 426, in plot_board
    fig, ax = plt.subplots(figsize=(img_width/dpi, 300/dpi), dpi=dpi)
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 1176, in subplots
    fig = figure(**fig_kw)
  File "/usr/lib/python3/dist-packages/matplotlib/pyplot.py", line 539, in figure
    **kwargs)
  File "/usr/lib/python3/dist-packages/matplotlib/backend_bases.py", line 171, in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
  File "/usr/lib/python3/dist-packages/matplotlib/backends/backend_tkagg.py", line 1049, in new_figure_manager_given_figure
    window = Tk.Tk(className="matplotlib")
  File "/usr/lib/python3.6/tkinter/__init__.py", line 2023, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Has anyone gotten it to plot? Or have any idea how to fix this error? I know it has to do with being on a remote server, but I have no idea how to fix it. Online explanations about errors similar to this one are going way over my head.

@mikeizbicki
Copy link
Owner

In the video, I pass the -X flag to ssh to enable X windows forwarding, which allows the lambda server to create windows on your computer. If you are using putty, then there's a checkmark to enable X windows forwarding that you'll have to find and check. There's people at the QCL who have done this in putty before, so they can help you find the right checkmark.

As an aside, graphical user interfaces (GUIs) "seem" much more userfriendly, but it is much harder to communicate these settings in GUIs. That's one of the main reasons why most programmers prefer CLIs (command line interfaces). It makes collaboration over the internet much easier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants