How to color data series point inside plot graph depending on data value in Excel table - excel

On a data/line plot inside Excel, I'd like to color my data points depending on a value inside the table on the same row as the data value, however from a different column.
It's best explained with a picture:
It's essentially a line chart type with the lines removed, and the data points set to bullet type and given an increased radius for visibility. The x-axis denotes the calendar date as dd.mm, and the y-axis contains the values.
Now the Excel table also contains a row called "Time of Day", which can be mo(rning), mi(dday), ev(ening).
Can something like this be done with a line chart, or do I need to use a different type of chart, or is this generally not possible in Excel (which I doubt)?
Excel in use is: Microsoft Excel for Mac, Version 16.51 (21071101).

Here's a way to achieve this:
What I've done is:
Added three columns for the times of day (columns B, C and D). These can be hidden.
Added this formula in B2: =IF($E2=B$1,$F2,NA()) which should then be dragged to cover the next two columns and then down to cover every day.
Selected A1:D11 (it'll be more than 11 on your version)
Went to Insert > Chart > Insert Line or Area Chart > Line With Markers
At this point you have a line chart with three series (mo, mi, ev). The lines can be removed, which just leaves the markers. You can format each series separately, with different colours, shapes, sizes, etc.
As a special bonus, this automatically gives you a legend that explains the colours.

Related

How to recreate a bar chart of event times in Excel

Trying to recreate this first graph in excel using the data below it.
Solved this by making the times regular integers, then calculating the start to end difference for each date, widening the data to split the differences among three categories. I then highlighted only the dates and start times, pressed control, and highlighted the 3 columns with the differences.
I selected stacked bar chart, which looked like this by default.
Lastly, I selected the (blue) start time bars and chose no fill as the color. After deleting this series from the legend, the result adequately matched the requirements.

I only want to see actual x values to show on horizontal axis of Excel Chart (with scale matching those values) not let Excel do scaling and labeling

Below is an Excel Chart for the data shown in column A (x-coordinates--dates) and column B (y-coordinates--test results). There's no problem with the column B data. But note that the horizontal axis shows quite a few more dates than are contained in column A.
Is there any way to have only the actual x-coordinates shown on the horizontal axis with a scale that matches those values?
I kind of get it. Excel deliberately scales the horizontal axis to match as best it can the data in column A. But I don't want that. Beneath each "corner" point of the graph, I'd like to see the date that is associated with the test result in column B.
In other words, there is clearly a point with y-coordinate 154.5. I'd like to see 2/13/2018 directly below that point since that is the data in row 5. Note that the x-axis contains the "correct" date for the first plotted point: (2/9/2017, 70). But for the point with y-coordinate 80, it looks as if that test result occurred on 6/9/2017 rather than 6/16/2018.
So I'd like the graph to appear as shown in the second image, which likely would be impossible because of the "crowding" of x-coordinate values at the right-hand end, but just displaying whichever of the three dates would fit would be good enough, as would just showing one of the two dates in other "crowded" areas. That is to say that something like the third image would be fine.
I suppose I could write VBA code to make it happen, but I'd prefer that Excel do it.
(What crosses my mind is, "Are exact dates really this important?" And the jury is still out on this point. There are arguments both ways. I guess a hung jury goes to the judge, Excel.)
By inserting the points to be plotted into two arrays, datesArr and scaledArr, and putting those values into columns A and B (see worksheet) and in code saying ...
Set ch = ActiveChart
Set s = ch.SeriesCollection
s(1).Values = scaledArray
s(1).XValues = datesArr
... I got exactly what I wanted. Now granted that's not exactly built-in, but we're programmers, yes? And this was downright easy. Well, once I learned a few tricks, especially being able to set angle of dates to 45 degrees.
You need to plot two sets of data, the actual values, and a set of zeros, then smoke and mirrors make it work.
Data below left, make a line chart (top left chart). Add data labels to the second series; I colored the labels orange to match the points, for clarity in this description. Default labels show Y values, which are all zero (top right). Format the data labels to show category values (i.e., dates), below the points, rotated upwards (bottom left). Format format format (bottom right). Axis labels: none. Format second series with medium gray lines and medium gray cross markers. Drag bottom of plot area upwards to make room for the date labels. Hide legend.

Excel Chart - Do not Hide Horizontal Data Label

I want to plot a simple chart with Date on the X axis and Number on my Y axis. Tried XY scatter but Excel try to be smart and hide my data labels.
Also, Excel tried to re-order my Date which I do not want.
Date POS
22/10/2017 7
01/10/2017 14
08/09/2017 8
11/08/2017 6
28/07/2017 4
09/07/2017 3
26/06/2017 4
09/06/2017 11
19/05/2017 8
23/04/2017 8
02/04/2017 5
19/03/2017 1
19/02/2017 3
05/02/2017 10
30/01/2017 8
08/01/2017 3
20/11/2016 13
11/11/2016 7
28/10/2016 12
16/10/2016 5
30/09/2016 7
16/09/2016 3
27/08/2016 8
14/08/2016 13
24/07/2016 3
17/07/2016 7
17/06/2016 2
27/05/2016 4
24/04/2016 16
10/04/2016 1
27/03/2016 2
04/03/2016 4
19/02/2016 4
24/01/2016 1
03/01/2016 1
Would like to see everything. Is it possible ?
Thanks.
To answer your questions:
Brief:
1) You can't see all your data labels on the X axis unless you format the X axis to have major interval of 1.
2) With a scatter plot, you cannot have your original labels retained on the X axis and, in your case, as your dates are recognised , they are ordered as such. You would need to convert the dates to text and plot as a line chart without the line.
Solution:
1) Right click X axis and set the major interval to a balance between the amount of detail you want to see and that which is legible. To see all data points, with data that are whole numbers, then 1 should do it, but may become very crowded, so a trade-off.
2) To stop the re-ordering of your dates: The trick is to convert your dates to text using =TEXT(A2,"dd/mm/yy") where A2 is a data point for the X axis etc. In the picture below, this is showing above B39, as I have transposed your original dataset, but the formula was pointing at your original vertical dataset. If that makes sense.
You arrange your data horizontally with each data point in its own column (i.e. transpose your original data set) and then plot this as a line chart and right click format data series > no line. Making sure markers are visible.
On an old Mac with Excel 2011, similar process for Windows and later Excel, removing the line would look like:
And you can select a line colour and add it back in:
Reference i gave in comments which reminded me to transpose the data is scatter-chart-with-one-text-non-numerical-axis
To be honest, if you are going to plot a line chart which has one axis which appears to be dates, it may confuse users if those dates are not then in order.
I recommend to convert all values to date and graph away with standard scatter plot...if you treat the dates as text, and then graph only the entries, then the variance between the dates can be very misleading (unless there are no gaps, 100% consistent).
Below is a snippit of text and of dates with your provided data. It is nearly identical, but not quite. If your data set is larger and there is larger variation between date entries then it will definitely provide a misleading chart.
If you go with the text path, change to line chart, hide line, set color to markers, and put the max interval to 1.
If you go with the date path, then you will not be able to read the x-axis with each date explicitly stated. There would be too many dates to display. You could add data labels to display in the plot area instead of the x-axis, but it is clutter.
You have stumbled across what many also find, that Excel stinks as a graphing tool. This is because about 10 years ago, Micro Soft went stupid and started trying to make software that is "really helpful for the user" translate "makes stupid decisions we don't want". One case in point is your problem.
Excel Line charts are not line charts; they are bar charts that just use lines instead of bars. The issue at hand is how different chart types treat the X-Axis. How you treat the X-Axis determines what kind of chart you use. There are basically only two kinds of X-Axis: discreet/continuous (aka. category/value). For example category would be something like color (RED/BLUE/GREEN). There is no "distance between colors" (what is the distance between red and blue?). Where as numbers and time have a concept of distance inherent in them. For example: how many days are there between jan-1-2001 and jan-10-2001? or What is the distance from the 10 yard line and the 20 yard line?
The problem is that to use charts in Excel, you have to know how each chart type treats the X-Axis. Most people would expect the LINE chart to treat the X-Axis as a value, but MS is not most people so they decided to treat it like a category (unless it is a date more on that in a moment). So, you cannot plot a number X-Axis on a line chart. You should use the XY SCATTER chart instead. Scatter chart in Excel assumes both axis are numbers and thus plots your numeric X-Axis in the expected manner.
if you use a line chart (or bar chart) and you double click your x-axis values, or right click them, you can go to their format axis page where you will see that you have the choice of treating the x-axis as text or dates, but not numbers. This is why when you sort your data differently in a line chart or bar chart, the chart changes, it is because the x-axis is being treated as a category and categories are plotted on the chart in the order they are seen in the data. This can be very useful when your x-axis really is a category but then if that were so you would most likely be using bar charts not line charts. My experience is that BAR charts and LINE charts in Excel behave exactly the same so consider that when thinking about using a line chart.
if your x-axis is a category use bar chart or pivot table and exploit sorting.
if your x-axis is a date use bar/line chart and mark it as date in format-axis page.
if your x-axis is a number use scatter chart.
if your data is something else, or you have a specific perspective you want to emphasize, then do some reading about the different chart types in Excel and pick the one that was created to show what you want to show.

Excel Line chart using start and end values as data

So I need to make a line chart, the columns will be split to 9 objectives, and the rows a 1-6 scale. USers are asked to rank themselves between 1 and 6 at the start and end of the course and I wish to show a line for each objective to signify the travel from point A. (start) to point B (end)Somehting like this:
I just can;t seem to make it work! Any suggestions?
In my opinion there are at least three possible approaches to this but each one has it drawbacks:-
(1) Just plot each Line separately as a Line graph and move it to a separate sheet (right-click and select Move Graph). Then you can put the graphs next to each other. The down-side is that it is rather fiddly and you may not want them to appear as separate graphs.
(2) Do the first graph as a Scatter using 1 and 2 as the x-coordinates and your first 2 points as the y-coordinates. Then do the next graph with x-coordinates 2 and 3 and use copy and paste to move it onto the same axes as the first graph (click on the line joining the points and use Ctrl-C and Ctlr-V to copy it onto the first graph). The downside is that each line copied in this way will come out in a different colour and once again it is fiddly to change it.
(3) Do the whole thing as one Scatter graph. You need to re-format the data as below to get some suitable coordinates. To get the break between the lines you need a genuine empty cell (not "" produced by a formula) so I suggest you copy the coordinates in pairs (e.g. F2:G3 to F5:G6) and leave every third pair of cells in the column empty. Then select the whole range F2:G27 and insert a Scatter with straight lines joining the points. Fix the X-axis range from 1 to 9.9 and the y-axis range from 1 to 6 and add axis labels and title as required. The downside of using a Scatter like this is that you only have numbers rather than text along the X-axis but it shouldn't matter in your case where you just need an objective number at each tick mark.
In F2:-
=INT((ROWS(F$1:F1)+2)/3)
In F3:-
=F2+0.9
In G2:-
=IFERROR(INDEX($B$2:$C$10,INT((ROWS(G$1:G1)+1)/3),MOD(ROWS(G$1:G1),3)),"")

How to draw line X=1?

I know how to draw a line with scatter plot options where X is the independent and Y the dependent variable.
In the scatter plot of that data I need to add another line: X=2. I have the following data:
But how to draw a line X=1 ?
Maybe you want something like this:
I hear that charting is more different than many other aspects of Excel between versions and that perhaps my version (Excel 2007) is one of the least ‘friendly’ hence some of the reason for “not very easy” but the principle is as #Bill the Lizard has described. In view of some weird behaviour with (my?) Excel 2007 however I recommend being careful about the sequence in which the lines are drawn.
First I suggest getting your chart right for all aspects but the green line. Then add another series with X values of 1 and 1 and Y=2 values of 10 and -2 (or whatever the limits are of your chosen y-axis as displayed). Select and copy that array (four cells) select your chart and Paste Special…, and Add cells as New Series, Columns, Categories (X Values) in First Column, OK.
This should add a vertical line of the same chart type as the existing (ie XY (Scatter) Scatter with Straight Lines and Markers). The colour can be changed, by selecting that series (click on it and Format Data Series…, Line Color etc) and presumably you would want the markers removed. It was these that for me at first refused to disappear to order – but persistence paid off. Click on either of the data points, and under Marker Options choose none for Marker Type. If necessary, repeat for the other data point – and keep repeating if required!
Also, I selected what was showing as Series3 (text) in the legend and deleted that.
Forgot to mention that for anything to do with Excel charts Jon Peltier is the ultimate authority (eg) and that an alternative approach is to use an error bar and a secondary vertical axis.

Resources