Home > Enterprise >  How to plot 1 dimensional data inside the 2 dimensional triangular coordinates with colorbar in pyth
How to plot 1 dimensional data inside the 2 dimensional triangular coordinates with colorbar in pyth

Time:10-28

I have closed triangle data coordinates a1 (size 10x1) and b1 (10x1), which creates the 3 closed triangles. I have another c1 data (size 3x1). I want to plot the c1 data over the triangle with colorbar. The image I'm attempting to create is similar to the matlab function patch(x,y,c). But I am unable to find a similar function in Python (Jupyter Notebook). Can someone suggest how to plot it?

The following is the sample data:

import numpy as np
import matplotlib.pyplot as plt

a1=[0.90899658,1.10720062,1.47019958,0.90899658,1.47019958,3.14479828,0.90899658,3.14479828,3.17749786,0.90899658]
b1=[-0.38689995,0.22739983,0.69180012,-0.38689995,0.69180012,-0.34249973,-0.38689995,-0.34249973,-0.38329983,-0.38689995]
plt.plot(a1,b1)

#creating triangular matrix of size 3x3 after avoiding last cordinate
a2=a1[0:9]
b2=b1[0:9]
a3=np.reshape(a2,(3,3))
b3=np.reshape(b2,(3,3))

# The data as a third function c1 for 3 triangles
c1=[0.234,0.034,0.006]

# ploting data
plt.fill(a3,b3)
plt.colorbar

The output figure should be like the following (created from Matlab):

screenshot of requested output figure

CodePudding user response:

I propose the following solution, you can edit the enter image description here

  • Related