How to create a scatter plot with multiple data

조회 수: 6 (최근 30일)
Aurelius Hardy
Aurelius Hardy 2022년 11월 28일
답변: Karim 2022년 11월 28일
nothing pops up when trying to create a scatter plot for the following data of Snow. I've attached the function of what I'm entering.
January: 8.48.
February 5.15
March 3.85
  댓글 수: 1
Florian Rössing
Florian Rössing 2022년 11월 28일
Could you provide Data and Code to replicate the Problem?

댓글을 달려면 로그인하십시오.

답변 (1개)

Karim
Karim 2022년 11월 28일
Hello, see below for a demonstation on how to make the scatter plot.
Note that it uses a 'crude' way to define the dates, probably you have more detailed information about the dates, it's better to use that. The main idea is to first define the dates as a string array. And the convert those strings into datetime's. Matlab is able to directly use datetimes in the figures.
Good luck!
% create a list of the months
Months = ["1" "2" "3"]; % make a string array of the months of intres (i.e. Jan, Feb and March)
Months = datetime(Months,'InputFormat','MM','Format','yyyy-MM') % convert to datetimes
Months = 1×3 datetime array
2022-01 2022-02 2022-03
% list the amount of snow per month
Snow = [8.84 5.15 3.85];
% create a scatter plot
figure
scatter(Months,Snow,75,'filled','r')
grid on
% label the y-axis
ylabel('Snow')
% Set the ticks in the figure to month information
ax = gca;
ax.XTick = Months;

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by