+ Reply to Thread
Results 1 to 10 of 10

Locking the origin on a scatter plot

Hybrid View

  1. #1
    Registered User
    Join Date
    05-11-2007
    Posts
    12

    Locking the origin on a scatter plot

    I need to make a chart that displays a phasor diagram. I have a column of cells containing the angles of the phasors. I made a scatterplot that has a separate series for each phasor and draws a line from (0,0) to wherever that phasor needs to be depending on the angle.

    Here's the catch, the angles are continuously updating and I need the chart to update as well. Right now, every time it updates, the origin moves around within the chart and is difficult to look at. Is there away to keep the origin locked in the center of the chart while the lines rotate around this origin?

    Thanks,

    Eric

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,596
    Excel doesn't have a built in algorithm for this. Excel's built in utility only allows you to fix the endpoints of the axes.

    How much variability will there be in (x,y)? If there is limited variability, then it might be easiest to fix the endpoints of your axes now, and then the origin won't move around.

    If there is enough variability that you need the endpoints to be flexible, your going to have to write your own algorithm (in VBA or other) that will look up the max and min for x and y, then determine suitable endpoints for the axes and then apply them to the axes, with the idea that the origin will remain in a fixed location. When I've done this, I've used worksheet functions in an out of the way part of the spreadsheet to calculate the desired axis limits, then a chart_calculate event to automatically apply those limits each time the chart "calculates"

  3. #3
    Registered User
    Join Date
    05-11-2007
    Posts
    12
    Sorry I took so long, I thought I would get an email when someone responded.

    How can you write an event for a chart? It doesn't seem to show up in VBA.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,596
    Did you put "calculate event" into the VBA help search engine? That worked for me. In your case, I don't know if it will be preferable to have the calculate event tied to the chart or the source worksheet. Tying events to embedded charts introduces a couple of complications that you have to sort out to get them to work. I've always used stand alone chart sheets, so I'm not familiar with these issues.

  5. #5
    Registered User
    Join Date
    05-11-2007
    Posts
    12
    For some reason, I don't see anything relevant when I search for calculate event in VBA. I also figured if I right-clicked on the chart in Design Mode, it would give me the option to Build Code, but it did not.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,596
    I know sometimes the VBA help search engine isn't that good at finding pertinent information.

    I would start by opening the VBA editor (alt-F11). Then navigate in the project explorer to the worksheet where you can then put your worksheet_calculate event procedure.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1