+ Reply to Thread
Results 1 to 5 of 5

Logarithmic y-axis with different base

  1. #1
    Registered User
    Join Date
    04-03-2014
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    27

    Logarithmic y-axis with different base

    Hi

    I am having big troubles with a logarithmic y-axis. How do you define the log base in VBA?

    ----------------
    Sub abc()

    Set sht = ThisWorkbook.Worksheets("sheet1")
    Set chtrng = sht.Range(sht.Cells(Rows.Count, 1).End(xlUp), sht.Cells(1, Columns.Count).End(xlToLeft))
    Set chtrngX = chtrng.Columns(1).Offset(1).Resize(chtrng.Rows.Count - 1)
    Set cht = sht.ChartObjects.Add(Left:=300, Width:=300, Top:=100, Height:=200)

    With cht.Chart
    .ChartType = xlXYScatterLinesNoMarkers
    .Axes(xlValue, xlPrimary).ScaleType = xlLogarithmic
    ' NEED HELP to change base unit of log scale eg. something like: _
    '.Axes(xlValue, xlPrimary).Base = 10

    For iSeries = 2 To chtrng.Columns.Count
    With .SeriesCollection.NewSeries
    .Values = chtrngX.Offset(, iSeries - 1)
    .XValues = chtrngX
    .Name = chtrng(1, iSeries)
    End With
    Next

    End With

    End Sub
    ----------------

    The data i have looks bad when the log base is 10. Default.


    Thanks for you help in advance!

    Regards
    damp

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Logarithmic y-axis with different base

    In vba the log base is defined as e. In Excel you can choose the log base for any number i.e. LOG (number;base)

    You should be able to select log base in vba using
    Please Login or Register  to view this content.
    Untested as I'm using my Android to post this.

    Alf

  3. #3
    Registered User
    Join Date
    04-03-2014
    Location
    Denmark
    MS-Off Ver
    Excel 2010
    Posts
    27

    Re: Logarithmic y-axis with different base

    It do not think i can use this. How do you use this for the y-axsis in the code? What would you put in "number"?

  4. #4
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Logarithmic y-axis with different base

    How do you define the log base in VBA?
    That was your question as I read your post and my answer was based on it.

    Alf

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Logarithmic y-axis with different base

    This forum can be strict about using code tags around code. Wrap your code to avoid getting the topic locked. The FAQ page explains how.

    If I understand what you are asking, I think you need to become familiar with the .logbase property of the axis object: https://msdn.microsoft.com/EN-US/lib.../ff835539.aspx
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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. How to plot a logarithmic graph with 2 y-axis?
    By kureoshin in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-18-2015, 10:22 AM
  2. Why is the second plot not using the logarithmic x axis?
    By DaveSnelling in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 03-24-2014, 07:23 PM
  3. Changing the x-axis values on a logarithmic chart?
    By c991257 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 10-30-2008, 07:18 AM
  4. Logarithmic x-axis
    By nsv in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-09-2006, 03:35 AM
  5. In the x axis, logarithmic scale
    By Charles in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 04-20-2006, 01:20 PM
  6. [SOLVED] logarithmic scale on x-axis
    By Daniel in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-08-2006, 10:30 PM
  7. Logarithmic axis
    By Peter Svendsen in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-06-2005, 08:05 AM

Tags for this Thread

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