Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary plot by reading data from a file with four columns #169

Closed
Masoom02 opened this issue Apr 25, 2021 · 1 comment
Closed

Ternary plot by reading data from a file with four columns #169

Masoom02 opened this issue Apr 25, 2021 · 1 comment

Comments

@Masoom02
Copy link

Masoom02 commented Apr 25, 2021

If you compile this (attached sample data file), you get ternary plot with colorbar but no points on it. Could you direct me where I am going wrong!

`
import ternary
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['figure.dpi'] = 200
matplotlib.rcParams['figure.figsize'] = (1,1)
figure, tax = ternary.figure(scale=1.0)
figure.set_size_inches(10,8)

tax.ticks(axis='lbr', multiple=0.2, linewidth=1, tick_formats="%.1f", offset=0.02)
tax.boundary()
tax.set_title("Plotting of sample trajectory datadata", fontsize=10)

Load some data, tuples (x,y,z)

points = []
with open("share_data.txt") as handle:
for line in handle:
points.append(list(map(float, line.split(' '))))
SCALE=1

Plot the data

#tax.plot_colored_trajectory(points, linewidth=2.0)

Shuffle points for additional plot

#points = [(x, y, z,i) for (i,x, y, z) in points]
d = dict()
for c, x, y, z in points:
d[(x,y,z)]=c

#print ("Dict: {}".format(d.items()))
tax.heatmap(d, scale = float(SCALE),style="triangular", cmap=plt.cm.get_cmap('YlOrRd'))
axes_colors = {'b': 'g', 'l': 'r', 'r': 'b'}
tax.boundary(linewidth=2.0, axes_colors=axes_colors)

tax.left_axis_label("$x_1$", offset=0.16, color=axes_colors['l'])
tax.right_axis_label("$x_0$", offset=0.16, color=axes_colors['r'])

tax.bottom_axis_label("$x_2$", offset=0.06, color=axes_colors['b'])

tax.gridlines(multiple=1, linewidth=2,
horizontal_kwargs={'color': axes_colors['b']},
left_kwargs={'color': axes_colors['l']},
right_kwargs={'color': axes_colors['r']},
alpha=0.7)
ticks = [i / float(SCALE) for i in range(SCALE + 1)]
tax.ticks(ticks=ticks, axis='rlb', linewidth=1, clockwise=True,
axes_colors=axes_colors, offset=0.03, tick_formats="%0.1f")

tax.clear_matplotlib_ticks()
tax.show()`
share_data.txt

@marcharper
Copy link
Owner

marcharper commented Apr 25, 2021

The heatmap function doesn't interpolate the data for you; it only colors the polygons the specified color. See here: #81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants