Bar chart with height and width

A

Andy

I want to be able to plot areas in a graph using the
information below. For example for row A I want to plot a
rectangle with corners (3,1)(3,2)(4,1)(4,2).

| x to x | y to y
----+---------------+--------------
a | 3 4 | 1 2
b | 6 7 | 2 4
c | 9 21 | 10 12

Any help would be appreciated.

Andy
 
A

Andy Pope

Hi Andy,

You would need to use an xy scatter chart.
And you will also need to expand your data points.

Your new data would be something like this;

3 1
3 2
4 2
4 1
3 1
<Blank> <Blank>
6 2
6 4
7 4
7 2
6 2
<Blank> <Blank>
9 10
9 12
21 12
21 10
9 10

By leaving the two rows of blanks you shouldn't get a line joining the
areas.
You can create the new expanded data by hand or with lookup formulas or
even using VBA code. And here is some VBA.

Sub MakeBoxes()
Dim rngBox As Range
Dim rngOutput As Range

' Assume output will start in B10
Set rngOutput = Range("B10")
' Assume XY data is in range B2:E4
For Each rngBox In Range("B2:E4").Rows
With rngBox
rngOutput.Cells(1, 1) = .Cells(1, 1)
rngOutput.Cells(1, 2) = .Cells(1, 3)
rngOutput.Cells(2, 1) = .Cells(1, 1)
rngOutput.Cells(2, 2) = .Cells(1, 4)
rngOutput.Cells(3, 1) = .Cells(1, 2)
rngOutput.Cells(3, 2) = .Cells(1, 4)
rngOutput.Cells(4, 1) = .Cells(1, 2)
rngOutput.Cells(4, 2) = .Cells(1, 3)
rngOutput.Cells(5, 1) = .Cells(1, 1)
rngOutput.Cells(5, 2) = .Cells(1, 3)
End With
Set rngOutput = rngOutput.Offset(6, 0)
Next
End Sub


I want to be able to plot areas in a graph using the
information below. For example for row A I want to plot a
rectangle with corners (3,1)(3,2)(4,1)(4,2).

| x to x | y to y
----+---------------+--------------
a | 3 4 | 1 2
b | 6 7 | 2 4
c | 9 21 | 10 12

Any help would be appreciated.

Andy

--

Cheers
Andy

http://www.andypope.info
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top