+ Reply to Thread
Results 1 to 6 of 6

How to add vertical line to existing chart?

Hybrid View

  1. #1
    Registered User
    Join Date
    06-14-2023
    Location
    Austin, tX
    MS-Off Ver
    2016
    Posts
    6

    How to add vertical line to existing chart?

    Please take a following attachment, mainly I just have 2 columns, strike price and OI. I used insert recommended chart, the clustered column chart is the one that looks best for me. I just wanted to dynamically add a vertical line to the chart with whatever the current price is (430.5). I tried to follow Mutiple examples online but my chart always look messed up after I try to add the vertical line. Any suggestions or help?
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,428

    Re: How to add vertical line to existing chart?

    I'm not sure what you tried. Here's what I did:

    1) I will need a dummy point/series for the current price. In E2, I enter =D2. In F2 I enter a value. I choose 120000 (something near the maximum).
    2) Add a new data series to the chart. In the Select data dialog, add a new data series using F2 for the values.
    3) Exit the select data dialog, select the new data series, and change the chart type of this series to "XY scatter".
    4) If Excel does not automatically add the secondary vertical and horizontal axes, format the new series to be on the secondary axis system and add both secondary axes.
    5) Back to the select data dialog and edit the new series so that it is use E2 for the X values.
    6) Format the secondary horizontal axis so that its min is 424.5 and its max is 449.5. This should make the two horizontal axes about the same, so that the horizontal position of the new series data point is between the 430 and 431 columns.
    7) Select the new series and add error bars. Delete the horizontal error bars. Format the vertical error bars to show only the negative error bar and set it to have a length of 100%.
    8) Format the secondary vertical axis so that it has the same limits as the primary vertical axis.
    9) Format the error bar and the data series to have the appearance you want.
    10) Any other formatting you want to apply.

    That should work for the specific example given. If I were to expand this to make it more flexible so that it would be easy to use for different data series, I would work out a different relationship between the secondary horizontal axis max and min and the value in E2. I would explore different combinations of values for the value in F2 and the secondary vertical axis max and min. I would need to know if I always expected the "strike prices" to always be very integer, or if it would be possible for these to be more scattered. And so on. But the basic idea would remain throughout all of those variations. Add an additional XY scatter data series to the chart with an error bar, and figure out the combination of axis limits and E2,F2 values that position the vertical line correctly.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    06-14-2023
    Location
    Austin, tX
    MS-Off Ver
    2016
    Posts
    6

    Re: How to add vertical line to existing chart?

    I appreciate the reply, another gentleman helped me out and I was able to get it to work by changing the chart type to xy scatter. Unless I misunderstood what you are saying, but is there any easy way to get it to work with column chart or make the scattered chart look like column chart? The problem I see is that excel doesn't know to use those horizontal labels as x axis to place the vertical line for the colum chart. Thanks.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,428

    Re: How to add vertical line to existing chart?

    Maybe something like this?

    1) Select A2:B26 -> Insert scatter chart (marker without lines).
    2) Select the data series -> Add error bars -> delete horizontal error bars -> only show negative error bar (100%).
    3) Format error bars to have the desired color and thickness. My copy of Excel defaults to a 5 point size marker, so a 5 point wide error bar line is the same thickness as the marker. Experiment until you find the line width and marker size/style that you like.
    4) Add a data series and tell it to use D2 (current price) and E2 (value near the top of the chart).
    5) Select the 2nd data series and add a 100% negative error bar. Format this error bar and the marker to get the look you want.
    6) Other formatting as desired.

    What do you think?

  5. #5
    Registered User
    Join Date
    06-14-2023
    Location
    Austin, tX
    MS-Off Ver
    2016
    Posts
    6

    Re: How to add vertical line to existing chart?

    I see what you are saying, by any chance is it possible to have 2 different color error bars? One for positive value if the OI is above 0 and another color for negative numbers? Thank you sir, I appreciate your help.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,428

    Re: How to add vertical line to existing chart?

    Standard approach to "conditional formatting of charts" is to split the data up into as many columns/data series as you have conditions. In your case, split the data into 2 columns/data series -- one for the above 0 data and the second for the below 0 data.

    See this tutorial: https://peltiertech.com/conditional-...-excel-charts/

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Interactive vertical line on line chart
    By SammyDC in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 01-06-2022, 08:28 AM
  2. Vertical line in a histogram (vertical bar chart)
    By AdamCPTD in forum Excel General
    Replies: 2
    Last Post: 11-18-2017, 03:04 AM
  3. [SOLVED] Display vertical line on stacked line chart already using primary and secondary axises
    By ben_hensel in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 09-05-2012, 10:21 AM
  4. How to create a vertical reference line on a time series line chart
    By Bladebgii in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-23-2012, 10:17 AM
  5. Vertical line in chart
    By joedrummer in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-23-2008, 07:26 AM
  6. vertical line chart
    By Larissa in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-03-2006, 12:10 AM
  7. [SOLVED] [SOLVED] How to add a vertical line to a Line Chart that aleady has 2 Y axi
    By ISUTUBBS in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-28-2005, 12:05 AM

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