How do I change the colors of my data points in a scatter plot?
    13 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Attached below is the code I am working with and the associated excel sheet. I need to be able to change the data point's color from the default of blue to red. I am relativly new to MatLab so explanations of code when answering would be greatly appricated but not necessary.
depth = xlsread('942 Raw data.xlsx', 'Sheet1', 'I:I');
bulkdensity = xlsread('942 Raw data.xlsx', 'Sheet1', 'L:L');
graindensity = xlsread('942 Raw data.xlsx', 'Sheet1', 'N:N');
porosity = xlsread('942 Raw data.xlsx', 'Sheet1', 'O:O');
voidratio = xlsread('942 Raw data.xlsx', 'Sheet1', 'P:P');
data = [depth bulkdensity graindensity porosity voidratio];
%%
data = sortrows(data,1);
depth = data(:,1);
bulkdensity = data(:,2);
graindensity = data(:,3);
porosity = data(:,4);
voidratio = data(:,5);
%%
depth = [0;depth];
N = diff(depth);
a = (bulkdensity - 1.024)*9.81.*N/1000;
Ov = cumsum(a);
%%
figure(1)
plot(porosity,depth(2:end),'.');
axis ij
xlabel ('Porosity(%)');
ylabel ('Depth(m)');
hold on
%%
figure(2)
semilogx(Ov,voidratio,'.');
xlabel('Sv');
ylabel('voidratio');
hold on
0 Commenti
Risposta accettata
  Voss
      
      
 il 2 Apr 2022
        Here is a link to the documentation explaining what the options and syntax are for changing line properties (including color) in plot (semilogx has the same options and syntax for this).
Below is how you might make those two plots red:
depth = xlsread('942 Raw data.xlsx', 'Sheet1', 'I:I');
bulkdensity = xlsread('942 Raw data.xlsx', 'Sheet1', 'L:L');
graindensity = xlsread('942 Raw data.xlsx', 'Sheet1', 'N:N');
porosity = xlsread('942 Raw data.xlsx', 'Sheet1', 'O:O');
voidratio = xlsread('942 Raw data.xlsx', 'Sheet1', 'P:P');
data = [depth bulkdensity graindensity porosity voidratio];
%%
data = sortrows(data,1);
depth = data(:,1);
bulkdensity = data(:,2);
graindensity = data(:,3);
porosity = data(:,4);
voidratio = data(:,5);
%%
depth = [0;depth];
N = diff(depth);
a = (bulkdensity - 1.024)*9.81.*N/1000;
Ov = cumsum(a);
%%
figure(1)
plot(porosity,depth(2:end),'r.');
axis ij
xlabel ('Porosity(%)');
ylabel ('Depth(m)');
hold on
%%
figure(2)
semilogx(Ov,voidratio,'r.');
xlabel('Sv');
ylabel('voidratio');
hold on
0 Commenti
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Creating, Deleting, and Querying Graphics Objects in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



