3D scatter with 2 different data sets as different colours

28 ビュー (過去 30 日間)
N/A
N/A 2020 年 2 月 12 日
編集済み: John Kelly 2024 年 4 月 15 日 22:48
I have 2 data sets in Kitap 1 and PLMS. I want to show this 2 datasets with different colours in one 3D scatter. I wrote this code but I have only yellow points with this. Can somebody help me for 2 different colours.
data=xlsread('Kitap1');
x=data(1:end,1);
y=data(1:end,3);
z=data(1:end,5);
data2=xlsread('PLMS');
xx=data2(1:end,1);
yy=data2(1:end,4);
zz=data2(1:end,3);
figure(1);
scatter3(xx,yy,zz,'r','filled');
hold on
scatter3(x,y,z,'y','filled');
hold off
grid on
xlabel('X(km)')
ylabel('a(m/s^2)')
zlabel('CO_2 emission(g/s)')
zlim([0 100])
  2 件のコメント
Subhadeep Koley
Subhadeep Koley 2020 年 2 月 12 日
編集済み: John Kelly 2024 年 4 月 15 日 22:48
Can you provide the Kitap1 and PLMS files?
Because in my end I can plot 2 different data in 2 different colours successfully (Refer the code below).
close all; clc;
% Random data1
x = 1:200;
y = 1:200;
z = rand(1, 200);
% Random data2
xx = 1:200;
yy = 1:200;
zz = rand(1, 200);
figure; scatter3(xx, yy, zz, 'r', 'filled');
hold on;
scatter3(x, y, z, 'y', 'filled');
hold off; grid on;
xlabel('X(km)'); ylabel('a(m/s^2)'); zlabel('CO_2 emission(g/s)');
N/A
N/A 2020 年 2 月 12 日
Here there are :)

サインインしてコメントする。

採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 2 月 12 日
Firstly your PLMS.xlsx file has some NaN values. Moreover, the variable x is identical with xx, y is identical with yy, and so on...
Therefore, the first scatter plot is being overlapped by the second scatter plot.
I have increased the marker size of the first scatter plot and decreased the marker size of the second scatter plot in the code below. It is clearly visible how the first scatter plot is being overlapped by the second scatter plot.
Hope this helps!
clc; close all;
data = xlsread('Kitap1.xlsx');
data2 = xlsread('PLMS.xlsx');
x = data(1:end, 1);
y = data(1:end, 3);
z = data(1:end, 5);
xx = data2(1:end, 1);
yy = data2(1:end, 4);
zz = data2(1:end, 3);
% Discarding NaN values
xx(isnan(xx)) = [];
yy(isnan(yy)) = [];
zz(isnan(zz)) = [];
figure;
scatter3(xx, yy, zz, 100, 'r', 'filled');
hold on;
scatter3(x, y, z, 40, 'y', 'filled');
hold off;
grid on;
xlabel('X(km)');
ylabel('a(m/s^2)');
zlabel('CO_2 emission(g/s)');
dualScatter.png

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by