matlab散点图折线图
When you were learning algebra back in high school, you might not have realized that one day you would need to create a scatter plot to demonstrate real-world results.
当您在高中学习代数时,您可能没有意识到有一天需要创建一个散点图来演示真实结果。
Back in school, the examples we had to plot always seemed silly. Hours spent studying for a test versus the test grade received. The height versus the weight of a group of people. Or the correlation between sales of hot coffee and the outside temperature.
回到学校后,我们不得不绘制的例子似乎总是很愚蠢。 学习测试所花的时间与收到的测试成绩的小时数。 一群人的身高与体重。 或热咖啡的销量与外界温度之间的相关性。
But as a working adult (or maybe just a curious one), there are many times you may actually need to use that grade school math.
但是,作为一个正在工作的成年人(或者可能只是一个好奇的成年人),实际上您可能实际上需要使用很多次小学数学。
And creating a scatter plot is definitely one of those times. There are so many real-world applications that a scatter plot offers that can help you or your audience to visualize data and what it means.
创建散点图绝对是那些时候之一。 散点图提供了许多现实世界中的应用程序,可以帮助您或您的观众可视化数据及其含义。
Let’s take you back to high school math for a second, because you very well may have left any and all knowledge of what a scatter plot is back at your doodled-on desk.
让我们回到高中数学上一秒钟,因为您很可能已经把所有关于散点图的知识都留在了涂鸦桌上。
什么是散点图? (What is a Scatter Plot?)
A scatter plot is a type of data visualization that shows the relationship between different variables. This data is shown by placing various data points between an x- and y-axis.
散点图是一种数据可视化形式,可显示不同变量之间的关系。 通过在x轴和y轴之间放置各种数据点来显示此数据。
Essentially, each of these data points looks “scattered” around the graph, giving this type of data visualization its name.
本质上,这些数据点中的每一个在图形周围看起来都是“分散”的,从而使这种类型的数据可视化具有名称。
Scatter plots can also be known as scatter diagrams or x-y graphs, and the point of using one of these is to determine if there are patterns or correlations between two variables.
散点图也可以称为散点图或xy图,使用其中之一是确定两个变量之间是否存在模式或相关性。
Take a look at this example of a scatter plot pulled from one of Visme’s templates.
看一下从Visme的一个模板中提取的散点图的示例。
Create your own scatter plot using this template. Edit and download here.
使用此模板创建自己的散点图。 在此处编辑和下载。
The two variables are the square footage of a home versus its price. We pulled a sample data set of a couple handfuls of homes to see if we could determine a relationship between these two variables.
这两个变量是房屋的平方英尺数与价格之间的差额。 我们提取了几个房屋的样本数据集,以查看是否可以确定这两个变量之间的关系。
As the x-axis goes from the smallest size to the largest, we can see that there is a slight positive correlation showing that as square footage increases, so does the price.
当x轴从最小尺寸变为最大尺寸时,我们可以看到略有正相关,表明随着平方英尺的增加,价格也随之增加。
Of course there could be other factors contributing to this, like location or recent renovations, but we can see from this scatter diagram that there is a correlation between the square footage and home cost.
当然,可能还有其他因素,例如位置或最近的装修,但从散点图可以看出,平方英尺与房屋成本之间存在相关性。
The patterns or correlations found within a scatter plot will have a few different features.
在散点图中找到的模式或相关性将具有一些不同的特征。
Linear or Nonlinear: A linear correlation forms a straight line in its data points while a nonlinear correlation might have a curve or other form within the data points.
线性或非线性:线性相关在其数据点中形成一条直线,而非线性相关在数据点中可能具有曲线或其他形式。
Strong or Weak: A strong correlation will have data points close together while a weak correlation will have data points that are further apart.
强相关或弱相关:强相关将使数据点靠在一起,而弱相关将使数据点靠得更远。
Positive or Negative: A positive correlation will point up (i.e., the x- and y-values are both increasing) while a negative correlation will point down (i.e., the x-values are increasing while the corresponding y-values are decreasing).
正或负:正相关将指向上(即x和y值都在增加),而负相关将指向下(即x值在增加,而相应的y值在减小)。
However, if you don’t see any of these features present within your graph, that means there’s no correlation between your data.
但是,如果您在图形中看不到任何这些功能,则意味着数据之间没有关联。
何时使用散点图 (When To Use a Scatter Plot)
Each type of chart or graph has its own rules for when it’s going to be the best data visualization to showcase your information.
每种图表或图形都有自己的规则,以决定何时将其作为最佳数据可视化来展示您的信息。
Let’s dive into the best times to use a scatter plot to visualize your data set.
让我们深入研究最佳时间,使用散点图可视化您的数据集。
使用散点图来确定两个变量是否具有关系或相关性。 (Use a scatter plot to determine whether or not two variables have a relationship or correlation.)
Are you trying to see if your two variables might mean something when put together? Plotting a scattergram with your data points can help you to determine whether there’s a potential relationship between them.
您是否要查看两个变量放在一起时是否有意义? 用数据点绘制散点图可以帮助您确定它们之间是否存在潜在的关系。
Let’s say you’re running an ice cream business, and you’re curious to see if there’s a pattern in why your sales have been low recently.
假设您经营一家冰淇淋店,并且很好奇最近是否有低迷的销售模式。
You might create a scatter plot to measure different factors, including outside temperature.
您可能会创建一个散点图以测量不同的因素,包括外部温度。
Make this scatter plot template your own. Customize it here.
将此散点图模板设为您自己的。 在这里自定义。
You always want to plot your scatter diagram with both the x-axis and the y-axis increasing as they go out so that you can determine correlation.
您始终希望绘制散点图,使x轴和y轴随着散布而增加,以便确定相关性。
As we can see in the above example, people tend to buy ice cream — a cold dessert — less often when the temperature is cold outside.
正如我们在上面的示例中看到的那样,当外界温度较低时,人们倾向于购买冰淇淋(一种冷甜点)。
当自变量具有多个因变量值时,请使用散点图。 (Use a scatter plot when your independent variable has multiple values for your dependent variable.)
Okay, let’s take it back to math class for a minute and go over what independent and dependent variables mean.
好吧,让我们回到数学课上一分钟,然后再讨论自变量和因变量的含义。
First of all, a variable is the thing you’re trying to track or measure. Every graph has two variables — an independent variable that is typically graphed on the x-axis and a dependent variable that is typically graphed on the y-axis.
首先,变量是您要跟踪或测量的事物。 每个图都有两个变量-一个通常在x轴上绘制的自变量和一个通常在y轴上绘制的因变量。
An independent variable is the controlled variable. This is what changes naturally, or what the person manipulating the experiment or graph changes.
自变量是受控变量。 这就是自然改变的东西,或者是操作实验或图形的人改变的东西。
A dependent variable is the variable that is being studied or measured. In the case of a scatter plot, it’s the variable that we’re looking to determine whether or not has a correlation with the independent variable.
因变量是正在研究或测量的变量。 就散点图而言,它是我们要确定与自变量是否相关的变量。
If you’re trying to determine if height and weight have a correlation, the height will be placed on the x-axis and weight will be placed on the y-axis, like in the example below.
如果要确定身高和体重是否相关,则将高度放在x轴上,将重量放在y轴上,如以下示例所示。
Create your own scatter plot with this template. Find the template here.
使用此模板创建自己的散点图。 在此处找到模板。
Because weight fluctuates much more than height, it’s likely that you could have different weights for the same height in your data, giving you more than one dependent variable value for each independent variable.
由于权重的波动远大于高度的波动,因此同一数据中的高度可能具有不同的权重,从而为每个自变量提供多个因变量值。
当两个变量配对得很好时,请使用散点图。 (Use a scatter plot when you have two variables that pair well together.)
If you have two variables that pair well together, plotting them on a scatter diagram is a great way to view their relationship and see if it’s a positive or negative correlation.
如果您有两个变量配对得很好,则将它们绘制在散点图上是查看它们之间的关系并查看其是正相关还是负相关的好方法。
For example, think about birth weight versus gestational age (how long the baby has been in utero). It would make sense that a baby who was able to grow inside its mother for longer would be larger, and therefore weigh more, correct?
例如,考虑出生体重与胎龄(婴儿进入子宫的时间)。 能够在母亲体内长一些的婴儿会更大,因此体重会增加,对吗?
Let’s take a look at this data on a scatter plot.
让我们在散点图上查看这些数据。
Make your scatter plot using this template. Find it here.
使用此模板制作散点图。 在这里找到它。
As we would expect, the longer a baby is able to “cook,” the more it tends to weigh at birth.
正如我们所期望的,婴儿能够“做饭”的时间越长,出生时体重就越重。
Other examples of variables that appear to go hand in hand would be hours worked versus money made, time studied versus test grade or price versus diamond size.
似乎还有其他变量的例子还有:工作时间与赚钱,研究时间与测试等级或价格与钻石尺寸。
何时不使用散点图 (When Not to Use a Scatter Plot)
Just as there are certain times that it makes sense to use a scatter plot to visualize your data, there are a couple of examples when you want to stay away from this type of chart.
正如在某些情况下使用散点图可视化数据是有意义的,当您想远离此类图表时,有几个示例。
当您的数据根本不相关时,请避免使用散点图。 (Avoid a scatter plot when your data is not at all related.)
There are certain variables that make it obvious that there’s no correlation, therefore a scatter plot would be a useless way to visualize your information.
有某些变量使它们之间毫无关联,这很明显,因此散点图将是一种可视化您的信息的无用方法。
For example, if you’re gathering a random survey on a classroom full of students, putting together the students’ varying heights and the number of pets they have at home would make no sense on a scatter plot.
例如,如果您要在教室里满是学生的情况下进行随机调查,那么将散布在不同地点的学生的身高和宠物的数量汇总在一起就毫无意义。
These two variables obviously have no relationship whatsoever, and while they can still be fun to graph, a bar chart (one for each data value) might be the better choice here.
这两个变量显然没有任何关系,尽管它们仍然很有趣,但是条形图(每个数据值一个)可能是更好的选择。
当数据集过多时,请避免使用散点图。 (Avoid a scatter plot when you have too large a set of data.)
When you have so much data in your scatter plot that it clogs up the entire graph, this is the result of overplotting.
当散点图中的数据太多而阻塞整个图形时,这是过度绘图的结果 。
Statistician Nathan Yau sums up this phenomenon pretty well in the below graphic:
统计员Nathan Yau在下图中很好地总结了这种现象:
As another example, take a look at the scatter plot below. It’s so dense that it essentially becomes one large blob, and it’s hard to read much from this kind of diagram.
作为另一个示例,请看下面的散点图。 它是如此的密集,以至于它实际上变成了一个大斑点,并且很难从这种图表中读到很多东西。
There are a few ways to counteract an overplotted scatter plot, though. First, consider using a heatmap that shows where the most point-heavy sections of your data are.
不过,有几种方法可以抵消过度绘制的散点图。 首先, 考虑使用热图来显示数据中最繁琐的部分所在的位置。
You could also color code various data sets, use translucent data points to create a heatmap-like effect and more.
您还可以对各种数据集进行颜色编码,使用半透明的数据点来创建类似热图的效果等等。
However, your best bet is to avoid using a scatter plot when you have so much data that it becomes a large blob.
但是,最好的选择是避免在数据量太大而成为大斑点时使用散点图。
散点图要注意的事项 (Things to Keep in Mind With a Scatter Plot)
As you take a look at your data, there are a few things to keep in mind when you decide to use a scatter plot to determine relationships or correlation.
当您查看数据时,在决定使用散点图确定关系或相关性时要牢记一些注意事项。
相关并不总是因果关系。 (Correlation is not always causation.)
Just because you might see a strong positive or negative correlation in your data does not necessarily mean that your independent variable is the reason your dependent variable is measuring the way it is.
仅仅因为您可能会看到数据中存在强的正相关或负相关性,并不一定意味着您的自变量就是您的因变量正在测量其方式的原因。
These are correlations, meaning that it appears that your independent variable does have some sort of effect on your dependent variable.
这些是相关性,这意味着您的自变量似乎确实会对您的因变量产生某种影响。
Let’s jump back into our ice cream sales example.
让我们回到我们的冰淇淋销售示例中。
While it may seem that the weather is the direct cause of a decrease in sales, there could be so many other factors that are leading to slower business.
尽管天气似乎是销量下降的直接原因,但可能还有许多其他因素导致业务放缓。
Perhaps there was a natural disaster like a hurricane that led to a mandatory evacuation and therefore less business. A new ice cream shop could have opened down the street creating competition that wasn’t there before.
也许发生了像飓风这样的自然灾害,导致强制撤离,因此生意减少了。 一家新的冰淇淋店本可以在大街上开张,从而创造出前所未有的竞争优势。
Some days people just don’t want to buy ice cream. And while, sure, the colder weather might be a factor, just because you see a correlation on a scatter plot does not mean you should take it as law.
有时候人们只是不想买冰淇淋。 当然,虽然寒冷的天气可能是一个因素,但仅仅是因为您看到散点图上的相关性并不意味着您应该将其视为定律。
您可以有多个因变量。 (You can have more than one dependent variable.)
Your data set might include more than one dependent variable, and you can still track this on a scatter plot.
您的数据集可能包含多个因变量,您仍然可以在散点图上对其进行跟踪。
The only thing you’ll want to change is the color of each dependent variable so that you can measure them against each other on the scatter plot.
您唯一要更改的是每个因变量的颜色,以便您可以在散点图上相对于它们进行度量。
Let’s take a look back at our height versus weight example.
让我们回顾一下身高与体重的示例。
In that scatter plot, we added two different dependent variables — male and female — to see if there was also a difference between those factors. We colored female points orange and male points brown so that we could differentiate between the two.
在该散点图中,我们添加了两个不同的因变量(男性和女性),以查看这些因素之间是否也存在差异。 我们将雌性点涂成橙色,将雄性点涂成棕色,以便我们可以区分两者。
This is another great way to avoid overplotting. Ensuring you’re color coding your data helps to set it apart so that you can see more of your points.
这是避免过度绘图的另一种好方法。 确保对数据进行颜色编码有助于将数据区分开,以便可以看到更多点。
如何使用Visme创建散点图 (How to Create a Scatter Plot With Visme)
Now that you know all about what a scatter plot is and when you do and don’t want to use one, let’s get started with our tutorial on how you can actually create one.
既然您已经了解了什么是散点图以及何时使用和不希望使用散点图,那么让我们开始学习如何实际创建散点图的教程。
There are 16 different chart types you can create right in Visme, and a scatter plot is only one of them! Learn more about how to get started below.
您可以在Visme中直接创建16种不同的图表类型 ,而散点图只是其中之一! 在下面详细了解如何入门。
1.从模板开始。 (1. Start with a template.)
There are several different starter scatter plot templates available right in Visme for you to jump into and start adding your data.
Visme中有几种可用的入门散点图模板 ,您可以跳入并开始添加数据。
Follow this link to discover more templates in the Visme library.
单击此链接可在Visme库中发现更多模板。
2.输入您的数据。 (2. Input your data.)
Click on the scatter plot, and the graph settings will appear along the left side of your editor. Click Chart Data to input your data.
单击散点图,图形设置将出现在编辑器的左侧。 单击图表数据以输入数据。
The x-axis information will go in the top row and the corresponding y-axis data will go in the bottom row. Be sure that all of your numbers on the x-axis are in numerical order from lowest to highest.
x轴信息将显示在顶部,相应的y轴数据将显示在底部。 确保在x轴上的所有数字均按从低到高的数字顺序排列。
If you have more than one dependent variable, simply add that information to the next row for a second variable, the fourth row for a third and so on.
如果您有多个因变量,只需将该信息添加到第二行的下一行,第四行添加第三行,依此类推。
You can also head over to the Import Data tab to import data you’ve already gathered in a Google Sheet or Excel file.
您也可以转到“ 导入数据”标签,导入已在Google表格或Excel文件中收集的数据。
3.标记您的轴。 (3. Label your axes.)
Head over to Settings, the third tab in the chart settings. Click to open the Axis tab. This is where you can customize your x- and y-axis information and ensure your scatter plot data is appearing correctly.
转到“设置” (图表设置中的第三个标签)。 单击以打开“ 轴”选项卡。 在这里您可以自定义x轴和y轴信息,并确保散点图数据正确显示。
The first thing you need to do is ensure that Treat labels as text is switched to Off, otherwise your scatter plot will look a bit more like a with dots.
您需要做的第一件事是确保将“ 将标签当文本”设置为Off ,否则散点图看起来更像带有点的a。
Give each axis a label dictating what the variable is and customize your fonts to match the rest of your design by clicking the gear icon next to each axis. Or, as you see here, you can use separate text areas to label your graph.
单击每个轴旁边的齿轮图标,为每个轴指定一个指示变量的标签,并自定义字体以匹配设计的其余部分。 或者,如您在此处看到的,可以使用单独的文本区域来标记图形。
Check out our article on font pairing to determine the best ones to use.
请查看我们有关字体配对的文章,以确定最适合使用的字体 。
4.颜色代码。 (4. Color code.)
You can fully customize every single part of your scatter plot in Visme’s editor. Choose a color for each of your dependent variable’s points, choose a color for your values, your axes and your chart title.
您可以在Visme的编辑器中完全自定义散点图的每个部分。 为每个因变量的点选择一种颜色,为值,轴和图表标题选择一种颜色。
Click on the colored box next to each variable or each label in your settings to access the color picker. Choose from colors you’ve used in the past and preset palettes, or click on the + sign to access Visme’s color picker.
单击设置中每个变量或每个标签旁边的彩色框以访问颜色选择器。 从过去使用的颜色和预设调色板中进行选择,或单击+号以访问Visme的颜色选择器。
Once you find colors that make sense for your content or your overall design, you can move onto the next step.
找到适合您的内容或整体设计的颜色后,即可继续进行下一步。
5.动画散点图。 (5. Animate your scatter plot.)
Last but not least, animate your scatter diagram! Animation comes with any type of graph or chart within Visme’s editor.
最后但并非最不重要的一点是,为散点图设置动画! 动画附带Visme编辑器中的任何类型的图形或图表。
There are five different animation types for you to choose from for your chart: Linear, Bounce, Elastic, Ease Out and Ease In.
图表有五种不同的动画类型供您选择:“线性”,“弹跳”,“弹性”,“缓出”和“缓入”。
Once you’ve completed your changes, simply click outside of the chart on your canvas, then you can download your scatter plot or share it online however you like.
完成更改后,只需在画布上图表的外部单击,即可下载散点图或根据需要在线共享。
轮到你 (Your Turn)
Ready to start plotting your own scatter plot? Check out Visme’s graph maker for yourself and start creating one of 16 different charts to help visualize your information.
准备开始绘制自己的散点图了吗? 亲自检查Visme的图表制作器 ,并开始创建16种不同图表之一,以帮助可视化您的信息。
Be sure to check out all of the scatter plot templates available to jumpstart your design, as well. We’re just here to make graph-making and graphic design easier for you.
一定要检查所有可用于启动设计的散点图模板 。 我们只是在这里为您简化图形制作和图形设计。
The original version of this post first appeared on Visme’s Visual Learning Center.
这篇文章 的 原始版本 首次出现在Visme的 Visual Learning Center中 。
翻译自: https://medium.com/@paymantaei/what-is-a-scatter-plot-and-when-to-use-one-2365e774541
matlab散点图折线图
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388789.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!