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')
CodePudding user response:
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")
CodePudding user response:
If you comment out the plt.show()
it should be fine.