Vendor software usually allows graphics exports. However, there are often subtleties in the vendor-formatted graphics that make them less than ideal for placement into presentations or papers. We show some examples here of vendor-formatted graphics compared to replotted versions.
%% Cell type:markdown id: tags:
Imports:
%% Cell type:code id: tags:
``` python
importnumpyasnp
importmatplotlib.pyplotasplt
importpandasaspd
importos
os.chdir('./vendor')
# this is not a standard Anoconda Python package, but it's very useful.
try:
frommatplotlib_scalebar.scalebarimportScaleBar
scalebar_imported=True
except:
print('Please install matplotlib-scalebar')
scalebar_imported=False
```
%% Output
3.0.1
%% Cell type:code id: tags:
``` python
importmatplotlib
ifmatplotlib.__version__.split('.')[0]<'3':
raiseImportError('Requires matplotlib 3.0.0 or higher')
```
%% Output
True
%% Cell type:markdown id: tags:
### In this case, the vendor also exports the data as an Excel file
The Python `pandas` library allows easy import of Excel. The variable `df` is a Pandas dataframe.
%% Cell type:code id: tags:
``` python
df=pd.read_excel('spectrum_out.xls',skiprows=24)
df.head()
```
%% Output
Channel Energy Counts Unnamed: 3 Unnamed: 4
0 0 -0.949805 0.0 NaN NaN
1 1 -0.939806 0.0 NaN NaN
2 2 -0.929807 0.0 NaN NaN
3 3 -0.919808 0.0 NaN NaN
4 4 -0.909809 0.0 NaN NaN
%% Cell type:markdown id: tags:
Reformat the data:
%% Cell type:code id: tags:
``` python
X=df['Energy'].values
X_range=(X<20)&(X>0.1)# discard data > 20 keV and < 0.1 keV
X=X[X_range]
Y=df['Counts'].values[X_range]
```
%% Cell type:markdown id: tags:
Set up the X-ray lines to label. This could easily be stored in an HDF5 file for simple lookup, rather than typed in manually: