How to convert highest points of histogram into a simple line graph

4 ビュー (過去 30 日間)
yu sh
yu sh 2016 年 8 月 31 日
コメント済み: Wouter 2018 年 11 月 9 日
I want to plot a line graph by simply connecting the highest points of each bar. In other words according to figure data I want to plot the frequency of theta in the form of connected line instead of bar. Kindly suggest. Secondly I want to do this because I want to plot multiple data on a single figure for comparison purpose, any suggestion how it can be done in a more presentable way if I have following type of several data.

採用された回答

dpb
dpb 2016 年 8 月 31 日
Huh--I answered this early this AM but it seems to have not "stuck"---
Use the histcounts function with defined edges vector for bins and the plot the results...
edges=linspace(1,160,31); % pick number of bins, points is 1+ that over your range
N = histcounts(X,edges); % get the counts in those bins
x=filter(edges,[0.5 0.5],1); % midpoint of bins; mean of edges
plot(x(2:end),N) % and plot...N.B. start with second x to get number bins wanted
  2 件のコメント
yu sh
yu sh 2016 年 8 月 31 日
Thanks a lot dpb!
Wouter
Wouter 2018 年 11 月 9 日
Perhaps semantics has changed over the years, but at least in 2018a, the third line should be 'x=filter([0.5 0.5],1,edges)'

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by