How to Color Points of a Scatter Plot by a Third Column
Step 1 : Set up the grid
|R, a free programming environment for statistical computing and graphics, comes with several sample data sets to give you some data to work with right away. We’ve entered part of the sepal and petal data into a Plotly grid. Our data includes measurements on sepal length and sepal width of 150 different irises, catagorized into three different species.
Once you’ve loaded the data, click Fork and edit to move the data into your Plotly workspace.
Step 2: Graph the data
|Select Scatter Plots from the MAKE A PLOT menu. Click choose as x and choose as y to specify the columns of $x$ and $y$ data. To color the data points by species, select Group By in the sidebar. Now you can select choose as G above the column of text, where the species information is contained. Click the blue Scatter plot button in the sidebar to create your graph.|
Step 3: Editing Your Graph
|Your graph should look something like this:|
|You can add or modify axis labels and the plot title by clicking and typing. Notice how the legend specifies the species of iris and each species has a different color on the plot.|
|Plotly graphs are interactive! You can hover over the scatter points for more information. Styling options are contained in the TRACES popover. Learn more about our interactive features in three short videos.|