Alex
Alex

Reputation: 172

Is there a way to view the plots from matplotlib within a docker container running on Ubuntu?

I am attempting to work on an image segmentation task from Kaggle (https://www.kaggle.com/hsankesara/unet-image-segmentation/data). I am running this on a docker container that I've set up on a server running in an Ubuntu console.

I'm relatively new to this, so I'm quite unsure about how to view the images produced by matplotlib within the docker container I've produced. The code just runs, and then exits - I'm left uncertain about what the outputs of the code are (as in what the filters for the CNN are) and I can't see any of the plots.

Many thanks!

Upvotes: 0

Views: 1776

Answers (1)

Sushant Agarwal
Sushant Agarwal

Reputation: 550

You can save the plots as a .png or .jpg files and download it from the Ubuntu server. This will help you view the plots as image file in your local system.

you can save the plots using

import matplotlib. some plot function as plt do some plotting `plt.save('path to save')

An example from Matplotlib.pyplot.savefig() in Python

# importing required modules 
import matplotlib.pyplot as plt
  
# creating plotting data
xaxis =[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
yaxis =[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  
# plotting 
plt.plot(xaxis, yaxis)
plt.xlabel("X")
plt.ylabel("Y")
  
# saving the file.Make sure you 
# use savefig() before show().
plt.savefig("squares.png")

enter image description here

After saving this file you can simply use some client to transfer data from the server. For FTP you can use FileZilla Client

Hope this solves the problem!!

Upvotes: 3

Related Questions