How to plot XRD data as 3D plot?
5 次查看(过去 30 天)
显示 更早的评论
I have a series of XRD diffractograms from a single sample, at different depths. I want to plot the spectra as a 3D line plot, as seen as below:
(From https://link.springer.com/article/10.1016%2FS1672-6529%2806%2960003-6)
I use the following code to view my XRD data in Matlab:
data = importdata('example_data.dat') ; % load the data from text file
semilogy(data(:,1),data(:,2)) ; % plot the data
How do I go from here?
TIA
0 个评论
采纳的回答
Star Strider
2021-9-7
编辑:Star Strider
2021-9-7
When I click on the link, I get a ‘DOI Not Found’ error. (EDIT — The new link is to an article behind a paywall, so I do not have access to it.)
That problem aside, if the data are in a matrix, it is likely possible just use surf to plot the matrix. The axis tick labels might need to be added manually in separate statements, however this is not difficult.
If you want to upload / attach the .XRD file, it would be necessary to put it into a .zip file first. Any information you have on its contents and format would be helpful, since I dioubt many here are familiar with that format (I am not, since .dat files can contain anything).
The complete matrix, with the values imported and plotted —
Uz = unzip('Plot3D[1].zip')
x = readmatrix(Uz{1}, 'Range','A:A')
ymtx = NaN(numel(x),numel(Uz));
for k = 1:numel(Uz)
ymtx(:,k) = readmatrix(Uz{k}, 'Range','B:B');
end
ymtx
figure
surf(ymtx, 'EdgeColor','none')
grid on
xticklabels = string(x);
yt = yticks;
NrYticks = 9; % Choose Any Integer Divisor of '54'
set(gca, 'YTick',linspace(min(yt), max(yt), NrYticks), 'YTickLabel',linspace(0, -54, NrYticks))
xlabel('x')
ylabel('y')
zlabel('z')
view(60,30)
% shading('interp')
Experiment to get different results.
.
10 个评论
Star Strider
2022-1-11
As always, my pleasure!
If you have further questions and have problems figuring out how the code works, don’t struggle longer than necessary. Just ask, and I’ll do my best to provide an appropriate solution (or explain the reason a solution isn’t possible).
更多回答(2 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!