Trying to increase marker size in scatter plot caused my plot and data to be replaced by a blank blue screen.
Mostra commenti meno recenti
I'm trying to plot a 2D (x,y), z response on a scatter plot. I had it working, but then wanted to change the size of the markers since they're a little small. I entered a few commands and nothing seemed to work because I got errors in the command window. Then all of a sudden my scatterplot was gone and replaced by a blank blue screen. No axes. Nothing. If i'm not in the range of my data, I get a white blank graph with x and y axes. I tried zooming out to see if perhaps I set my marker size to something huge...also no luck.
I have tried entering set(gcf, 'Renderer', 'painters') and set(gcf, 'Renderer', 'opengl') into the command window. Nothing changed.
I suspect I accidentally set something on my computer because I have two different versions of matlab on my laptop (student) and both are having this error.
T is an imported 258 x 5 excel file containing data points. This is my base code. I am using MATLAB R2020a and reran in R2020b to see if I had the same issue. Thanks.
clc
clear all
close all
% This code was made assuming a pitot tube would be used for tunnel readings
% 1. insert dat or xml file with tunnel test section wall data
% Note: Dynamic Pressure is Total - Static
T=readtable('TS specs.xlsx');
% 2. Plot data to determine where wall fluctuations are.
scatter(T.X,T.Y,T.Dynamic_Pressure,'MarkerFaceColor','flat')
xlabel('X Coordinate (mm)')
ylabel ('Y Coordinate (mm)')
title ('Dynamic Pressure along Axial ODU SST Tunnel Walls')
ylim([1e-3 12e-3]);
xlim([-0.017 -0.008]);
Pictures: All are after one run of my code.
- What pops up when I run my code.

2. I am able to click on a data point, but can't see it or others.

3. Outside out my data range limit I can see a blank plot with axes.

SOLVED.
For anyone else with the same issue, I updated my code to:
pointsize = 2;
scatter(T.X, T.Y, pointsize, T.Dynamic_Pressure);
cb=colorbar()
which has solved all of my issues. Benjamin's answer was correct. My plot was interpreting the third input as size. I now have a 2D plot with 3 vectors and a color gradient for the 3rd vector.

2 Commenti
Can you attach the data or a snippet of it so that the issue can be reproduced. Obviously, I can throw together placeholder data, but that doesn't exactly prove anything, since the scaling is unknown and possibly relevant.
scatter(rand(1,30),rand(1,30),100*rand(1,30),'MarkerFaceColor','flat')
xlabel('X Coordinate (mm)')
ylabel ('Y Coordinate (mm)')
title ('Dynamic Pressure along Axial ODU SST Tunnel Walls')
Brittany Davis
il 30 Nov 2021
Risposta accettata
Più risposte (1)
You're dealing with 2D data, so ideally you'd be using 3 dimensions to visualize it. That said, there are only 2 unique values for Y. This might suggest a simplification. You'll have to decide what's appropriate or meaningful.
T = readtable('TS specs.xlsx');
nl = size(T,1);
% do a 3D scatter plot
scatter3(T.X,T.Y,T.Dynamic_Pressure,'MarkerFaceColor','flat')
As you can see, the data forms two salient groups. A stacked 2D plot may suffice.
% split Y into two series using scatter
figure % reset web-plot
hold on
h1 = scatter(T.X(1:nl/2),T.Dynamic_Pressure(1:nl/2),'red','MarkerFaceColor','flat');
h2 = scatter(T.X(nl/2+1:end),T.Dynamic_Pressure(nl/2+1:end),'blue','MarkerFaceColor','flat');
legend([h1 h2],{sprintf('Y = %.5f',T.Y(1)) sprintf('Y = %.5f',T.Y(end))})
Since the data is ordered, it might be easier to read details with a simple line plot.
% split Y into two series using plot instead
figure % reset web-plot
hold on
h1 = plot(T.X(1:nl/2),T.Dynamic_Pressure(1:nl/2),'r');
h2 = plot(T.X(nl/2+1:end),T.Dynamic_Pressure(nl/2+1:end),'b');
legend([h1 h2],{sprintf('Y = %.5f',T.Y(1)) sprintf('Y = %.5f',T.Y(end))})
You'll have to add back the title and labels, etc.
Categorie
Scopri di più su Discrete Data Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



