Set width of vector interval to plot.
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
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일
0 개 추천
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
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.
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.
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?
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.
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
