No scalar values when saving a matplotlib plot of 2D image data
Found with ParaView 5.7.0
We are using the following programmable filter to save a matplotlib plot within a catalyst script:
import matplotlib.pyplot as plt
import numpy as np
import vtk
from vtk.util.numpy_support import vtk_to_numpy
PNGOutputFilename = "plot.png"
indata = self.GetInput()
array = indata.GetPointData().GetArray("RTData")
if (array):
np_array = vtk_to_numpy(array)
plt.close()
plt.plot(np_array)
plt.savefig(PNGOutputFilename)
With 2D image data, we get the error:
No scalar values found for texture input!
The image of the plot does still get saved, but this error causes the in situ use case to hang.
To recreate (In the GUI):
- Sources -> Wavelet -> Apply
- Filters -> Slice -> Apply
- Filters -> Resample to Image -> set the dimensions to 1,100,100 -> Apply
- Filters -> Programmable Filter -> copy and paste the script above -> Apply