How do I change the colors of my data points in a scatter plot?
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Voss
2022-4-2
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Purple 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!