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

6 次查看(过去 30 天)
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 个评论
Eamon Reynolds
Eamon Reynolds 2020-7-14

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).

请先登录,再进行评论。

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by