Cannot delete text added to scatter plot points (2024)

18 views (last 30 days)

Show older comments

Matt on 30 Jul 2015

  • Link

    Direct link to this question

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points

  • Link

    Direct link to this question

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points

Edited: dpb on 30 Jul 2015

Open in MATLAB Online

Hello!

I have an issue regarding TEXT items. I have a scatter plot which works fine, then I am adding to the points some simple labels using the TEXT function. It works fine, but at some point I want to update the plot which means items are removed from the scatter plot.

When I use the TEXT function again, it adds labels to the updated points, but keeps the old text in place. There is no point on the graph because it has been deleted, but the label remains although obsolete.

Using the DELETE function didn't solve the issue.

Here is my code for the scatter plot and the text labels:

set(panel3.pl1, 'XData', pointM(:,1), 'YData', pointM(:,2), 'SizeData', sizedata, 'CData', colordata);

legend1=text(pointM(:,1), pointM(:,2), c, 'Color', 'g', 'FontWeight', 'bold');

Then what I am doing is just deleting the legend1 item using a pushbutton, but it doesn't work.

Any clue?

1 Comment

Show -1 older commentsHide -1 older comments

dpb on 30 Jul 2015

Direct link to this comment

https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301162

  • Link

    Direct link to this comment

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301162

If it's in a GUI; I'm guessing that most likely problem is that you haven't passed the handle legend1 in a way such that it is available to the GUI. What does "doesn't work" mean, precisely? IOW, what error or other symptoms are there? Have you used debugger to step thru the callback function?

Sign in to comment.

Sign in to answer this question.

Answers (2)

Star Strider on 30 Jul 2015

  • Link

    Direct link to this answer

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#answer_187700

  • Link

    Direct link to this answer

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#answer_187700

Open in MATLAB Online

I don’t know what about delete didn’t work for you, since we don’t have enough of your code to experiment with it.

For an example, see if this (archive) code snippet (that deletes the label for point 10) suggests a solution:

N=20;

area=100;

X=rand(1,N)*area;

Y=rand(1,N)*area;

for i=1:N

hp(i) = plot(X(i),Y(i));

ht(i) = text(X(i),Y(i),num2str(i),'fontsize',10);

hold on

end

XY=[X;Y]';

Q10 = XY(10,:); % Get Coordinates Of Point To Be Deleted

delete(hp(10)) % Delete Plotted Point

delete(ht(10)) % Delete Text Label

2 Comments

Show NoneHide None

Muthu Annamalai on 30 Jul 2015

Direct link to this comment

https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301180

  • Link

    Direct link to this comment

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301180

Open in MATLAB Online

I was going to add the following comment, but it is superfluous in the light of relativity of simultaneity ... :-)

@Matt, @dpb - I wonder if you make the figure current via

fig_handle = scatter(...)

figure(fig_handle)

delete(txt_handle)

it should be able to delete the object.

dpb on 30 Jul 2015

Direct link to this comment

https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301195

  • Link

    Direct link to this comment

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301195

Edited: dpb on 30 Jul 2015

Whether the figure is in focus or not makes no difference; the handle refers to the object directly without reliance on any other hierarchy.

I don't follow at all why OP would think there's even any possibility he can delete the object using its handle if he doesn't pass that handle to a new scope (the second button's callback function that tries to do the dirty).

Sign in to comment.

Matt on 30 Jul 2015

  • Link

    Direct link to this answer

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#answer_187701

  • Link

    Direct link to this answer

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#answer_187701

Edited: Matt on 30 Jul 2015

Basically I have 1 pushbutton that adds points to the pointM matrix, as well as the color and size parameters for the scatter plot, and then another pushbutton that remove points from that pointM matrix. I can successfully see the points being added and removed from the scatter plot.

When I add points, the labels are added accordingly which is good, and when I remove points, the labels are updated accordingly.

Thing is that when some points are deleted, the labels are not so I end up having labels next to nothing as the point has been deleted.

I shouldn't have to pass the legend1 text handle from one button to the other since I just want to delete it and then re-create it.

Hope it helps!

1 Comment

Show -1 older commentsHide -1 older comments

dpb on 30 Jul 2015

Direct link to this comment

https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301175

  • Link

    Direct link to this comment

    https://matlabcentral.mathworks.com/matlabcentral/answers/231762-cannot-delete-text-added-to-scatter-plot-points#comment_301175

Edited: dpb on 30 Jul 2015

"... 1 pushbutton that adds points ... then another ... that remove[s] points...I shouldn't have to pass the legend1 text handle from one button to the other since I just want to delete it ..."

How is the delete button to know what to delete and get access to it if it doesn't have the handle? Of course you have to pass it (or have access to it by some other method such as (ugly) making it global).

ADDENDUM

OK, there is a way other than passing; use findobj or similar technique in the "delete" callback routine to uncover the handle of the desired text object. This'll entail having some way to ascertain "who's who in the zoo" of all the possible text entities that may be present to make sure it's the right one (like keeping a tag or somesuch).

But, however you do it, you must somehow have the handle associated with the specific text object you wish to remove in the context of the function doing the deleting. That you make it in some other function is immaterial once you leave that function you're operating in a new scope and any and everything that was defined inside that function is gone when you leave unless it was made persistent or you passed it back out as a return value or made it global (again, Ugly!) or whatever...

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphicsFormatting and AnnotationLabels and AnnotationsAnnotations

Find more on Annotations in Help Center and File Exchange

Tags

  • scatter
  • delete
  • label

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


Cannot delete text added to scatter plot points (8)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

Cannot delete text added to scatter plot points (2024)

FAQs

What button should be pressed to delete text to be deleted? ›

The correct answer is Delete Key. It is used to put information into a computer or give it instructions by typing. A key is one of the keyboard's buttons.

How to clear text from figure in Matlab? ›

To clear the contents of a figure, you can alternatively use Clear Figure from the figure window's Edit menu.

Why can't you delete a text? ›

Sometimes, if you can't delete a message, it's an issue with your carrier or its service, but occasionally a message can just get stuck.

What key do you press to delete text? ›

  1. To delete one word to the right press CTRL+DEL.
  2. Both the Del or Delete key and Backspace key are used to delete text. ...
  3. If not, here's a quick way to duplicate the forward delete functionality on a Mac laptop. ...
  4. In Microsoft Word this is accomplished by pressing, often accidentally, the INS (Insert) key.

How do you clear content in MATLAB? ›

To clear one or more specific variables from the current workspace, use clear name1 ... nameN . To clear all variables from the current workspace, use clear or clearvars . To clear all global variables, use clear global or clearvars –global .

What is erase mode in MATLAB? ›

This mode erases the object and anything below it (such as grid lines).

What is the erase function in MATLAB? ›

newStr = erase( str , match ) deletes all occurrences of match in str . The erase function returns the remaining text as newStr . If match is an array, then erase deletes every occurrence of every element of match in str .

Which button can be used to remove text? ›

The delete key (often abbreviated del) is a button on most computer keyboards which is typically used to delete either (in text mode) the character ahead of or beneath the cursor, or (in GUI mode) the currently-selected object. The key is sometimes referred to as the "forward delete" key.

Which key deletes text? ›

Answer: Both the Del or Delete key and Backspace key can delete text. However, when dealing with text, pressing the Del key deletes text to the right of the cursor. Pressing the Backspace key deletes text to the left (backwards) of the cursor.

How do I delete text messages? ›

Inside the settings menu, find and select the "Delete all messages" or a similar option. Confirm the deletion when prompted. All your text messages will be deleted. After following these methods, you'll have successfully deleted text messages on your Android phone or tablet.

What to press to delete permanently? ›

To permanently delete a file:

Select the item want to delete. Press and hold the Shift key, then press the Delete key on the keyboard.

References

Top Articles
Cranberry Orange Sauce Recipe
Delicious Gordon Ramsay Bacon Jam Toast Recipe - TheFoodXP
Epguides Succession
Musas Tijuana
Current Time In Maryland
Jay Cutler of NFL Biography, Wife, Career Stats, Net Worth & Salary
Cost Of Fax At Ups Store
Best Seafood Buffet In Laughlin Nevada
Creglist Tulsa
Mensenlinq: Overlijdensberichten zoeken in 2024
Tinyzonehd
Weldmotor Vehicle.com
Barefoot Rentals Key Largo
Tyson Employee Paperless
Jinx Manga Vyvy
Paul Mccombs Nashville Tn
Haunted Mansion Showtimes Near Roxy Lebanon
Sofia the baddie dog
Ihop Logopedia
Justine Waddell talks about a season of screenings MELODIA!
Ff14 Cloth Softening Powder
2024 Coachella Predictions
Estrella Satánica Emoji
Icl Urban Dictionary
Wdef Schedule
Fgo Spirit Root
Craigslist Quad Cities
Pechins Ad
O'reilly's In Mathis Texas
Mylaheychart Login
Missing 2023 Showtimes Near Lucas Cinemas Albertville
Olentangy Calendar
Advance Auto Parts Near Me Open Now
Qmf Bcbs Prefix
Eddie Murphy Cast Of Elemental
Obsidian Guard's Skullsplitter
2005 Chevy Colorado 3.5 Head Bolt Torque Specs
Palmer Santin Funeral Home Fullerton Nebraska Obituaries
Hendrick Collision Center Fayetteville - Cliffdale Reviews
20 Fantastic Things To Do In Nacogdoches, The Oldest Town In Texas
Weather Tomorrow Hourly At My Location On Netflix Movies
Pho Outdoor Seating Near Me
MyEyeDr. near Lind<b>ergh Center Metro Station
Wells Fargo Arena Des Moines Seating Chart Virtual View
Blog:Vyond-styled rants -- List of nicknames (blog edition) (TouhouWonder version)
Tapana Movie Online Watch 2022
Used Cars For Sale in Pretoria | Quality Pre-Owned Cars | Citton Cars
Dungeon Family Strain Leafly
The many times it was so much worse
Democrat And Chronicle Obituaries For This Week
C Weather London
Carenow Urgent Care - Eastchase Fort Worth Photos
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 6812

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.