+ Reply to Thread
Results 1 to 3 of 3

Scatter plot hide legend items with no data behind

  1. #1
    Registered User
    Join Date
    03-05-2015
    Location
    Amsterdam, The netherlands
    MS-Off Ver
    2016
    Posts
    2

    Scatter plot hide legend items with no data behind

    Dear all,

    I have a file with two sheets one with the data (example below) that gets filled out of matlab and one sheet that presents a scatter chart of the data with various lines (in the legenda a through e). It's possible that randomly one of the columns with the data has only zero's/no data see the example below like the column 'c'.

    a b c d e
    1 1 0 1 1
    2 2 0 2 2
    3 3 0 3 3
    4 4 0 4 4
    5 5 0 5 5

    Is there a possibility without doing this manually hide the 'c' column from the legenda when the excel file is automatically filled by matlab.

    Tnx for any help
    Attached Files Attached Files
    Last edited by -Switch-On-; 10-20-2020 at 04:49 AM.

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

    Re: Scatter plot hide legend items with no data behind

    After a day without response, I will venture something. As far as I know, there is not built in way to do this except manually. As with most things in Excel, you can write a VBA macro procedure that will do the same thing that you are doing manually. In this case, you would use LegendEntries(index).Delete method to remove a legend entry (LegendEntry Object help file: https://docs.microsoft.com/en-us/off...dentry(object) ). One thing to keep in mind is that, as explained in the help file, there is no way to resurrect a legend entry once deleted. You would need to delete the legend and recreate it, so an approach that involves deleting legend entries is probably best applied to a template file where you are always starting with the full legend before importing the data from matlab. You have not explained how the data is getting into Excel from Matlab, so this may or may not easily integrate into your current importation strategy.

    Some charting experts are not fond of legends at all. If you are not required to use a legend, these types prefer using a data label on one point (often first or last point, but not necessarily) in the data series. The advantage of this approach for your purpose would be when the data series is blank, there is no data point to plot and, therefore, no data label is visible in the chart, and it would be automatic. The main difficult I foresee is whether you can easily choose the data point to label up front and always use the same point, or if you need a complicated algorithm to decide which point to label after the data are imported. But, your OP was about legends, so I'm not sure if this kind of approach would be allowed.

    Do either of those options seems workable?
    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
    03-05-2015
    Location
    Amsterdam, The netherlands
    MS-Off Ver
    2016
    Posts
    2

    Re: Scatter plot hide legend items with no data behind

    Thank you for your reply. I guess we're going to work something else out then.

+ 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. Adding correlating names to the legend on a scatter plot (Mac)
    By colemc18 in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 11-30-2023, 07:44 AM
  2. [SOLVED] Hide legend items in a graph when associated value = zero or blank
    By bdicarlo1 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 06-07-2018, 06:44 AM
  3. Replies: 1
    Last Post: 12-19-2016, 01:26 PM
  4. [SOLVED] Scatter Plot, with legend?
    By dpsersimon in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-02-2013, 09:33 PM
  5. Legend to follow scatter plot colors
    By skorpan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-24-2011, 10:09 AM
  6. scatter plot colors/legend
    By liquidspaces in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-25-2008, 08:10 PM
  7. [SOLVED] Chart Legend Items: hide/show
    By Richard Ahlvin in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 09-05-2005, 11: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