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

7 ビュー (過去 30 日間)
Philipp Mueller
Philipp Mueller 2016 年 9 月 1 日
コメント済み: Eamon Reynolds 2020 年 7 月 14 日
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.
  1 件のコメント
Philipp Mueller
Philipp Mueller 2016 年 9 月 1 日
@Thorsten Danke für die Antwort. How does it work? sorry for this question i am a beginner.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by