Is it possible to define the marker size of a rectangle (length/width)?

15 views (last 30 days)
I want a rectangle marker. The size (length and width) should be defined.
clc
clear all
coordinate_x= linspace(0,100,10);
coordinate_y= rand(size(coordinate_x));
value=rand(size(coordinate_x));
colorbar('location','Manual', 'position', [0.93 0.1 0.02 0.81]);
x = coordinate_x
y = coordinate_y
a=13%markersize
c = value
axes_definition=gca
fig = gcf %figure handling
test=scatter(x,y,a,c,'filled')
colorbar;
  1 Comment
Eamon Reynolds
Eamon Reynolds on 14 Jul 2020

tldr, plot horizontal line segments

While Matlab does not offer rectangular markers, there are possibly a few ways to get something that looks like one.

My favorite is to define a new matrix M=[xdata-c; xdata+c; ydata]; where c is some constant equal to half the width of your rectangular marker and then plot the lines between these points using something like plot([M(i,1) M(i,2)], [M(i,3) M(i,3)]) within a for loop that iterates i.

In that same line you can specify the height of the rectangle by adjusting the line width (along with other specifications)

Now you can easily plot lines between the data points from the sides of your rectangular marker or from the middle if desired. Doing this for scattered data might be impractical, but it’s nice for certain purposes (like mapping the energy profiles for chemical reaction pathways).

Sign in to comment.

Accepted Answer

Thorsten
Thorsten on 1 Sep 2016
A rectangle is not among the markers. You have to draw it manually.

More Answers (0)

Categories

Find more on Chemistry 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!