×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

X-Y scatter plot axis range

X-Y scatter plot axis range

X-Y scatter plot axis range

(OP)
Anybody know a good way to set the axis range limits of a scatter plot equal to values in a few cells?

RE: X-Y scatter plot axis range

ivymike:

I could only get it to work on the y-axis.  Here is the code I used though...

Sub ChangeAxis()
    With Charts("Chart1").Axes(xlValue)
        .MinimumScale = Worksheets("Sheet1").Range("A1")
        .MaximumScale = Worksheets("Sheet1").Range("A2")
    End With
End Sub

here the min value for the y-axis is in cell "A1", max value in "A2".  I'm still trying to figure out the x-axis... If I figure it out, I'll let you know.

jproj

RE: X-Y scatter plot axis range

Ok, disregard that last one... I played around and figured it out:

Sub ChangeAxis()
    With Charts("Chart1").Axes(xlPrimary)
        .MinimumScale = Worksheets("Sheet1").Range("A1")
        .MaximumScale = Worksheets("Sheet1").Range("A2")
    End With

    With Charts("Chart1").Axes(xlSecondary)
        .MinimumScale = Worksheets("Sheet1").Range("A3")
        .MaximumScale = Worksheets("Sheet1").Range("A4")
    End With
End Sub

xlPrimary changes the x-axis and xlSecondary changes the y-axis. (so Xmin = A1, Xmax = A2, Ymin = A3, and Ymax = A4)
I wasn't able to run the macro unless the chart was in it's own sheet, but I'm sure that's just a matter of referencing it correctly.  (If you haven't already noticed, I haven't ever done this before).

Anyway, I hope this helps!

Jproj

RE: X-Y scatter plot axis range

Ok, (last one)... here's another way I got it to work using a chart on "sheet1" with a command buttom on the same sheet:

Private Sub CommandButton1_Click()
    With Worksheets("Sheet1").ChartObjects("Chart 1").Chart.Axes(xlCategory)
        .MinimumScale = Worksheets("Sheet1").Range("A1")
        .MaximumScale = Worksheets("Sheet1").Range("A2")
    End With

    With Worksheets("Sheet1").ChartObjects("Chart 1").Chart.Axes(xlValue)
        .MinimumScale = Worksheets("Sheet1").Range("A3")
        .MaximumScale = Worksheets("Sheet1").Range("A4")
    End With
End Sub

Good Luck!

jproj

RE: X-Y scatter plot axis range

(OP)
Oops, sorry, I wasn't specific enough in my original question.  I know how to do a one-time adjustment by the method you mentioned, I was wondering if there was a good way to tie the max and min of the axis to a particular pair of cells, such that updates to those cells are automatically reflected in the chart.  I'd like to set the chart up to automatically scale to accomodate new data, but the built-in auto scaling isn't getting the picture right.

RE: X-Y scatter plot axis range

I'm doubt you want to do this, but you could assign a macro to your chart.  The only other way I can think to do this is to have an "Update Now" command button that updates each axis for the max and min values of your data range.  Either of these ways, you'll have to click on something to update your chart.  I don't know how (or if it's even possible) to update your chart upon changing any cell.

Sorry for all the worthless postings

jproj

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close