Creating a Line Graph

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
Platform
  1. Windows
I work with Excel a lot, but have never really had the need to use graphs. For the project I'm working on, I'd like to use some. I'd like to run the values of a column along the bottom of the graph (the X axis?), and have the values of a few other columns serve as the actual lines (the Y axis?). I managed to build everything, but can't seem to get the values of the X axis to appear at the bottom of the graph. Instead, they appear smack dab in the middle of the graph.

Eventually, I'd like to have the chart created in vba, but I'm trying to build it manually first, so that I know exactly what I'm looking for.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
It looks like that will help me create the code, once I get to that point. Allow me to ask another question. Is there a way to limit the chart to only pulling in certain records? For instance, the minimum date and the 3 max dates from a column? I'm concerned that the size of the chart may get quite large, making it less useful.
 
Upvote 0
one way is to hide columns or rows, don't know if thats what you need to do
 
Upvote 0
... but can't seem to get the values of the X axis to appear at the bottom of the graph. Instead, they appear smack dab in the middle of the graph....

You most likely have negative values in the data. An example:

[TABLE="width: 256"]
<tbody>[TR]
[TD="class: xl64, width: 64"][/TD]
[TD="class: xl64, width: 64"]Alpha[/TD]
[TD="class: xl64, width: 64"]Beta[/TD]
[TD="class: xl64, width: 64"]Gamma[/TD]
[/TR]
[TR]
[TD="class: xl64"]Q1[/TD]
[TD="class: xl64, align: right"]2[/TD]
[TD="class: xl64, align: right"]-1[/TD]
[TD="class: xl64, align: right"]1[/TD]
[/TR]
[TR]
[TD="class: xl64"]Q2[/TD]
[TD="class: xl64, align: right"]1[/TD]
[TD="class: xl64, align: right"]0[/TD]
[TD="class: xl64, align: right"]-2[/TD]
[/TR]
[TR]
[TD="class: xl64"]Q3[/TD]
[TD="class: xl64, align: right"]0[/TD]
[TD="class: xl64, align: right"]1[/TD]
[TD="class: xl64, align: right"]-2[/TD]
[/TR]
[TR]
[TD="class: xl64"]Q4[/TD]
[TD="class: xl64, align: right"]-1[/TD]
[TD="class: xl64, align: right"]2[/TD]
[TD="class: xl64, align: right"]1[/TD]
[/TR]
</tbody>[/TABLE]

Plots like this, by default:

HnL0ljU.png


If you have a fixed limit vertical axis,
Select the vertical or y-axis.
In the format pane, select the small icon that looks like a column chart.
Under Axis Options, in the section headed "Horizontal axis crosses", select the "Axis value" radio button.
Type in the y-value where you want the x-axis to cross. In my example, I entered -3.

v3qL7HM.png


You can move just the labels.
Select the horizontal or x-axis.
In the format pane, select the small icon that looks like a column chart.
In the section titled "Labels", change "Label Position" to "Low".

747Lu8x.png
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top