- Create sample copies of the filled area, centered on (0,0) and extending to [-1, 1] . Now create one hg transform object for each destination location, and copyobj() the sample object to parent it to the hg transform object, and set the Matrix property of the hg transform object to scale and translate it to the desired position. This approach has the advantage of only having to figure out the hatch pattern once per different hatch. This approach has the disadvantage of requiring separate copies of the objects and seperate hg transform objects for each desired location.
- Create extensive Vertices and Faces lists combining all of the hatch objects to be created, and create a single patch() object that combines information for all of the hatches together. This approach has the advantage of only using a single graphics object. This approach has the disadvantage of making it more difficult to program the hatch objects and to program different colors for the different objects.
How to add pattern fill to markers in scatter plot?
50 views (last 30 days)
Show older comments
Elmira Ramazanova
on 7 Nov 2024 at 20:51
Commented: Elmira Ramazanova
on 11 Nov 2024 at 18:14
I want to add pattern fill to markers in scatterplot. It can easily be done in Excel (example befow). Is it possible to reproduce this in Matlab? I have seen user-defined functions in the file exchange like hatchfill2 but they seem to work well on bar plots and patch objects but not markers in scatter plot.
0 Comments
Accepted Answer
Walter Roberson
on 7 Nov 2024 at 21:15
There is unfortunately no simple way to add hatch filling.
To apply hatch filling, there are two possibilities:
2 Comments
Adam Danz
on 8 Nov 2024 at 16:16
3. A workaround to providing a hatch is to duplicate the scatter markers with + - | . x * symbols. This won't unfortunately, show up in the legend, though.
hold on;
s = scatter(rand(1,20),sort(rand(1,20)),randi(50,1,20)+40, 'c','filled','MarkerEdgeColor','k');
s2 = copyobj(s,s.Parent);
s2.Marker = '+';
p = scatter(rand(1,20)+.8,sort(rand(1,20))+.3,randi(50,1,20)+40, 'm','filled','MarkerEdgeColor','k');
p2 = copyobj(p,p.Parent);
p2.Marker = '.';
More Answers (0)
See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!