'Plot your own Data in pythong using pyrolite
So this is the example code from pyrolite. This example uses preexisting example data, but I would like to plot my own data.
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pyrolite.plot import pyroplot
from pyrolite.util.synthetic import example_spider_data
df = example_spider_data(noise_level=0.1, size=20)
ax = df.pyroplot.REE(color="0.5", figsize=(8, 4))
plt.show()
df.pyroplot.REE(mode="fill", color="0.5", alpha=0.5, figsize=(8, 4))
plt.show()
fig, ax = plt.subplots(1, 2, sharey=True, figsize=(12, 4))
df.pyroplot.REE(ax=ax[0])
# we can also change the index of the second axes
another_df = example_spider_data(noise_level=0.2, size=20) # some 'nosier' data
another_df.pyroplot.REE(ax=ax[1], color="k", index="radii")
plt.tight_layout()
plt.show()
I tried this:
d = open("XXX.txt", 'r')
for row in d:
row = row.split(' ')
names.append(row[0])
marks.append(float(row[1]))
And now I thought I could just exchange the example_spider_data with d, but I cannot. 'iOTextIOWrapper' object is not callable. I understand that d is not callable sounds logical, but how to create something callable? Or how to figure out where I can read about this?
How do I figure out which format the data needs to be in? I cannot find any help on this. In the documentation they always use example data...
Thank you very much in advance.
I only ever programmed stupid useless university exercises but would like to plot some real data now. I plotted stuff before, but I cannot grasp how to load in your data in python. I used some tutorials, but I doesn't work with pyrolite or rather I just don't not how I can be made to work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
