0

I am trying to download some plots as images and these are being downloaded as blank images. The direct download works but the download through the drive shows blank images. ANY HELP WOULD BE HIGHLY APPRECIATED PLEASE.

If I try to directly download the image, it is as expected, however, if I try through collab, it downloads the blank image. The concern is, I must try this method, I need to create a dataset and direct download is useless in this scenario. This is my code:

''' # MTF transformation, CONVERSION PROCESS mtf = MarkovTransitionField(image_size =24) X_mtf = mtf.fit_transform(df_sittingcolAx)

# Show the image for the first time series 

plt.figure(figsize =(5, 5)) 
plt.imshow(X_mtf[0], CMap ='rainbow')
plt.title('Markov Transition Field', fontsize =18) 
plt.colorbar(fraction =0.0457, pad =0.04) 
plt.tight_layout()
plt.savefig("eee.png") 
plt.show()

from google.colab import drive
drive.mount('/content/gdrive')
!touch "/content/gdrive/MyDrive/eee.png"
from google.colab import files
files.download('/content/sample_data/eee.png')
Sehr Malik
  • 11
  • 2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 11 '22 at 12:21
  • Thanks for the consideration, sorry seems I was not specific. – Sehr Malik Nov 11 '22 at 20:11
  • Thanks for the consideration, sorry seems I was not specific. I have a dataset, and I am drawing its plots. After the plotting work, I have to save those plots and create an image dataset of those plots. But the issue is, after showing plots, I am trying to save them in onedrive, then running a code to download them. However, this downloads a blank graph/image. My finding is that, there is something wrong when I am downloading that plot(image) from onedrive. As I have confirmed that, if I save that plot on Google collab folder, it downloads it manually, it works as expected. – Sehr Malik Nov 11 '22 at 20:19

2 Answers2

1

This issue has been fixed. below lines of code should be replaced with the ones that I shared in the next code block

plt.savefig("eee.png") 
drive.mount('/content/gdrive')
!touch "/content/gdrive/MyDrive/eee.png"
from google.colab import files
files.download('/content/sample_data/eee.png')

correct line of code:

plt.savefig("/content/drive/MyDrive/eee.png") 
Sehr Malik
  • 11
  • 2
0

If you comment out the plt.show() it should be fine.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 11 '22 at 23:30
  • I already tried to comment out plt.show() and even now I tried it again, it does have any impact. Same outcome. – Sehr Malik Nov 12 '22 at 10:49