Histogram inside a plot.

19 ビュー (過去 30 日間)
Priya
Priya 2014 年 3 月 18 日
回答済み: Vedant 2025 年 2 月 7 日 10:36
I have a histogram which I wish to be plotted inside a scatter plot at the bottom left corner.
I tried using the following but it did'nt work:
handaxes2 = axes('position', [-5 -5 1 1]);
nbins = 100;
hist(dev,nbins);
set(handaxes2, 'box', 'off');
  1 件のコメント
Youssef  Khmou
Youssef Khmou 2014 年 3 月 18 日
which part did not run normally?

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

回答 (1 件)

Vedant
Vedant 2025 年 2 月 7 日 10:36
Hi @Priya,
The position property of the axes function determines the position with respect to the bottom-left corner of the container (typically a figure, panel, or tab). Specifying negative values for the left and bottom attributes of the position property will move the histogram image out of the figure and does not achieve your intended purpose. To keep the image in the bottom-left corner of the scatter plot, we can use small but positive values for the “left” and “bottom” attributes, and we will be able to achieve the desired results. For more information about this, you can refer to the following documentation:
Additionally, I modified the code so that it works as intended in MATLAB R2014a.
insetPosition = [0.15, 0.15, 0.2, 0.2]; % [left, bottom, width, height]
insetAxes = axes('Position', insetPosition);
hist(dev, 100);
set(insetAxes, 'Box', 'off');
Using this code on a random sample data, we get the output as below:

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by