Matplotlib의 색칠된 선분
다양한 방법을 통해 뚜렷한 색상의 선을 그릴 수 있습니다. 선호되는 접근 방식은 렌더링할 선 세그먼트 수에 따라 다릅니다.
소형 선 세그먼트 수
소수 선 세그먼트(예: 10개 미만)의 경우 다음 접근 방식으로 충분합니다. :
<code class="python">import numpy as np import matplotlib.pyplot as plt # Define line segment data xy = (np.random.random((10, 2)) - 0.5).cumsum(axis=0) # Create figure and axes fig, ax = plt.subplots() # Iterate through line segments for start, stop in zip(xy[:-1], xy[1:]): x, y = zip(start, stop) ax.plot(x, y, color=np.random.rand(3)) plt.show()</code>
많은 수의 라인 세그먼트
많은 수의 라인 세그먼트(예: 천 개 이상)의 경우 LineCollections가 보다 효율적인 솔루션을 제공합니다.
<code class="python">import numpy as np import matplotlib.pyplot as plt from matplotlib.collections import LineCollection # Define line segment data xy = (np.random.random((1000, 2)) - 0.5).cumsum(axis=0) # Reshape data into segments xy = xy.reshape(-1, 1, 2) segments = np.hstack([xy[:-1], xy[1:]]) # Create figure and axes fig, ax = plt.subplots() # Create LineCollection with random colors coll = LineCollection(segments, cmap=plt.cm.gist_ncar) coll.set_array(np.random.random(xy.shape[0])) # Add LineCollection to axes ax.add_collection(coll) ax.autoscale_view() plt.show()</code>
색상 선택
두 방법 모두 "gist_ncar" coloramp에서 무작위 색상 선택을 사용합니다. 더 많은 선택 항목을 보려면 http://matplotlib.org/examples/color/colormaps_reference.html
을 참조하세요.위 내용은 Matplotlib에서 컬러 라인 세그먼트를 그리는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond

pythonisnotpurelynlogreted; itusesahybrideprophorfbyodecodecompilationandruntime -INGRETATION.1) pythoncompilessourcecodeintobytecode, thepythonVirtualMachine (pvm)

ToconcatenatelistsinpythonwithesameElements, 사용 : 1) OperatorTokeEpduplicates, 2) asettoremovedUplicates, or3) listComperensionForControlOverDuplicates, 각 methodHasDifferentPerferformanCeanDorderImpestications.

PythonisancerpretedLanguage, 비판적 요소를 제시하는 PytherfaceLockelimitationsIncriticalApplications.1) 해석 된 언어와 같은 thePeedBackandbackandrapidProtoTyping.2) CompilledlanguagesLikec/C transformt 해석

useforloopswhhenmerfiterationsiskNownInAdvance 및 WhileLoopSweHeniTesslationsDepoyConditionismet whilEroopsSuitsCenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTherInatismet, 유용한 광고 인 푸트 gorit


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

Eclipse용 SAP NetWeaver 서버 어댑터
Eclipse를 SAP NetWeaver 애플리케이션 서버와 통합합니다.

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.