user2305193
user2305193

Reputation: 2059

scatterhist with filled dots

I can produce a figure like this in Matlab

scatterhist(log(rand(1,100)),log(rand(1,100)),'Marker','o','Direction','out');

however I trying to get filled dots instead of open circles as markers seems surprisingly hard to do: Parameters used in the function scatter do not seem applicable in scatterhist. A quick Google didn't help, other stackoverflow show similar diagrams.

How to get filled point markers (optimally half-transparent)?!

Thanks

enter image description here

Upvotes: 2

Views: 1169

Answers (1)

Guto
Guto

Reputation: 541

What you want to do is add 'markerfacecolor','b' to the options, but by some reason, Matlab removed this option of the scatterhist.

You can do it by hand, changing the graph properties after you plotted. markerfacecolor options appears when you select the axis with the scatter and using the options >Edit >Figure properties.

Or you can use the following commands:

scatterhist(log(rand(1,100)),log(rand(1,100)),'Marker','o','Direction','out');
x=get(gca,'children')
x = 
  Line with properties:
              Color: [0 0.447 0.741]
          LineStyle: 'none'
          LineWidth: 0.5
             Marker: 'o'
         MarkerSize: 6
    MarkerFaceColor: 'none'
              XData: [1x100 double]
              YData: [1x100 double]
              ZData: [1x0 double]

  Show all properties

 set(x,'markerfacecolor','k')

I set the color as black, you can set in whatever color you want.

The transparency in a scatter plot is set by 'markerfacealpha',0.2 and 'markeredgealpha',0.2 (0.2 is the ratio in this case). However it does not work for the scatterhist (at least until Matlab 2017a). If you need the transparency, better to use the scatter and histograms using subplot. It is more time consuming but shall do the job.

Upvotes: 2

Related Questions