Set width of vector interval to plot.
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi!
I want to plot a vector where certain elements are somehow "better" and should be plotted as thicker lines. Still they should be the same line, only that it is thicker during some parts.
採用された回答
Rik
2018 年 2 月 21 日
I doubt this is possible with a single line object, but you can still do this. You can use the fact that plot will stop plotting at a NaN-value and resume when normal values occur again. So you can use your definition of better to replace the values that are worse with NaN. Then you just need to use hold(gca,'on') and plot again, with LineWidth set to a larger value.
7 件のコメント
Hampus Alfredsson
2018 年 2 月 21 日
Ok, like I suspected...but your solution could do the job! The only problem is that I will do approximately 10 line plots and probably want to make 5-10 intervals thicker in each of them. It will become a large plot.
Rik
2018 年 2 月 21 日
I don't fully understand your problem. Could you give an example? The number of intervals doesn't really matter, as plot will just resume the plotting for valid intervals.
Hampus Alfredsson
2018 年 2 月 21 日
I have a long matrix of coordinates representing the geographic movements of several bus lines. Whenever two or more bus lines use the same road(set of coordinates) this should be noted somehow. The more bus lines using the same coordinated should increase the thickness of these coordinates later in my plot. Don't know how to give a better explanation than this.
Rik
2018 年 2 月 21 日
As long as you insert NaN-values when you overlay the thicker lined plot, there shouldn't be a difference. You can even use a loop to go over all pair widths.
Hampus Alfredsson
2018 年 2 月 21 日
Ok, so if I use this example with some vectors:
A = [1 2 3 4];
B = [3 5 6 2];
C = [7 8 9 3];
All numbers that are repeated should be plotted as thicker. So number 2 should be a bit thicker and number 3 should be the most. How would you do?
Rik
2018 年 2 月 22 日
So you are actually plotting a graph. There is a built-in that does that (since R2015b). You can even supply the weights for each edge. The example code below is from the graph.plot doc. The doc for the graph function itself can be found here.
s = [1 1 1 1 2 2 3 4 4 5 6];
t = [2 3 4 5 3 6 6 5 7 7 7];
weights = [50 10 20 80 90 90 30 20 100 40 60];
G = graph(s,t,weights)
LWidths = 5*G.Edges.Weight/max(G.Edges.Weight);
plot(G,'EdgeLabel',G.Edges.Weight,'LineWidth',LWidths)
The s and t vectors contain the starting node index and terminal node index for each edge (=line in your plot). The weight determines the thickness of each line.
Hope this helps. I don't think you have supplied enough information for me to provide an example with your data.
Hampus Alfredsson
2018 年 2 月 22 日
Thank you very much @Rik Wisselink
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Geographic Plots についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
