How do I combine these two line plots together using seaborn? - seaborn

I want to combine these two plots together into one. What is the recommended approach to do this? Is there a way to do it using a single dataframe?
sns.relplot(x="epoch", y="loss", kind="line", color='orange', ci="sd", data=losses_df);
sns.relplot(x="epoch", y="loss", kind="line", color='red', ci="sd", data=val_losses_df);
My data for first is the following, with columns in this order ['epoch'], ['loss']
losses_df
0.0 0.156077
0.0 0.013558
0.0 0.007013
1.0 0.029891
1.0 0.008320
1.0 0.003487
2.0 0.017474
2.0 0.006232
2.0 0.002457
3.0 0.013332
3.0 0.004897
3.0 0.001900
4.0 0.010947
4.0 0.003905
4.0 0.001594
5.0 0.009127
5.0 0.003195
5.0 0.001341
6.0 0.007751
6.0 0.002681
6.0 0.001157
7.0 0.006605
7.0 0.002218
7.0 0.000972
8.0 0.005630
8.0 0.001867
8.0 0.000832
9.0 0.004839
9.0 0.001671
9.0 0.000748
val_losses_df
0.0 0.048945
0.0 0.006090
0.0 0.002332
1.0 0.024670
1.0 0.006243
1.0 0.002337
2.0 0.022344
2.0 0.006609
2.0 0.002626
3.0 0.022037
3.0 0.007156
3.0 0.003080
4.0 0.022025
4.0 0.008209
4.0 0.003835
5.0 0.022751
5.0 0.009226
5.0 0.004209
6.0 0.024093
6.0 0.009950
6.0 0.004783
7.0 0.025410
7.0 0.011130
7.0 0.005279
8.0 0.028299
8.0 0.012204
8.0 0.005969
9.0 0.028623
9.0 0.013037
9.0 0.006519
And my plots so far (except I want them combined in one plot with a legend)

You could combine the two dataframes to one:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
# losses_df = pd.read_csv(...)
# val_losses_df = pd.read_csv(...)
losses_df['type'] = 'losses'
val_losses_df['type'] = 'val_losses'
combined_df = pd.concat([losses_df, val_losses_df])
sns.relplot(x="epoch", y="loss", kind="line", hue="type", palette=['orange', 'red'], ci="sd", data=combined_df)
plt.tight_layout()
plt.show()

relplot() is a Figure level function that creates a new Figure at each call.
Use lineplot() instead.
fig, ax = plt.subplots()
sns.lineplot(x="epoch", y="loss", color='orange', ci="sd", data=losses_df, ax=ax);
sns.lineplot(x="epoch", y="loss", color='red', ci="sd", data=val_losses_df, ax=ax);

Related

saving dataframe and corresponding chart in a single pdf file in python matplotlib

I have a dataframe:
id1 id2 fields valid invalid missing
0 1001.0 0.0 State 158.0 0.0 0.0
1 1001.0 0.0 Zip 156.0 0.0 2.0
2 1001.0 0.0 Race 128.0 20.0 10.0
3 1001.0 0.0 LastName 158.0 0.0 0.0
4 1001.0 0.0 Email 54.0 0.0 104.0
... ... ... ... ... ... ...
28859 5276.0 36922.0 Phone 0.0 0.0 8.0
28860 5276.0 36922.0 Email 1.0 0.0 7.0
28861 5276.0 36922.0 State 8.0 0.0 0.0
28862 5276.0 36922.0 office ID 8.0 0.0 0.0
28863 5276.0 36922.0 StreetAdd 8.0 0.0 0.0
with an initial goal of grouping into individual id and create a pdf file. I was able to create a pdf file from the plot I created but I would like to save the dataframe that goes with the graph in the same pdf file.
# read the csv file
cme_df = pd.read_csv('sample.csv')
# fill na with 0
cme_df = cme_df.fillna(0)
# iterate through the unique id2 in the file
for i in cme_df['id2'].unique():
with PdfPages('home/'+'id2_'+str(i)+'.pdf') as pdf:
cme_i = cme_df[cme_df['id2'] == i].sort_values('fields')
print(cme_i)
# I feel this is where I must have something to create or save the table into pdf with the graph created below #
# create the barh graph
plt.barh(cme_i['fields'],cme_i['valid'], color = 'g', label='valid')
plt.barh(cme_i['fields'],cme_i['missing'], left = cme_i['valid'],color='y',label='missing')
plt.barh(cme_i['fields'],cme_i['invalid'],left = cme_i['valid']+cme_i['missing'], color='r',label='invalid')
plt.legend(bbox_to_anchor=(0.5, -0.05), loc='upper center', shadow=True, ncol=3)
plt.suptitle('valid, invalid, missing', fontweight='bold')
plt.title('id2: '+ str(i))
pdf.savefig()
plt.clf()
my code above prints the table in the results window, then goes to creating the horizontal bar. the last few lines save the graph into pdf. I would like save both the dataframe and the graph in a single file.
In some searches, it suggested to convert to html then to pdf, I cannot seem to make it work.
cme_i.to_html('id2_'+str(i)+'.html')
# then convert to pdf
pdf.from_file(xxxxx)

SVG SMIL animateTo works fine in Firefox but not in Chrome or Safari

The fill bottle animation working fine in firefox but not working in chrome and safari.
I am trying to fill the color in the bottle based on the textbox value entered by the user.
<script type="text/javascript">
function process(ele) {
if(event.key === 'Enter') {
Array.from(document.getElementsByClassName("animatedStop")).forEach((animation) => {
animation.setAttribute("to", ele.value + "%");
animation.beginElement();
});
}
}
</script>
<div style="float:left;">
<label>Enter Value</label>
<input id="fill-color" type="textbox" min="0" max="100" name="fillcolor" value="20" onkeydown="process(this)" />%
</div>
<svg id="octocat" version="1.0" xmlns="http://www.w3.org/2000/svg" width="150" height="450" viewBox="0 0 640 1280">
<defs>
<linearGradient id="gradient" x2="0%" y1="100%" y2="0%">
<stop offset="0%" stop-color="#df1c2a"/>
<stop offset="0%" stop-color="#df1c2a">
<animate class="animatedStop" attributeName="offset" from="0%" to="0%" dur="3s" fill="freeze" begin="0s"/>
</stop>
<stop offset="20%" stop-color="black">
<animate class="animatedStop" attributeName="offset" from="0%" to="0%" dur="3s" fill="freeze" begin="indefinite"/>
</stop>
</linearGradient>
</defs>
<path id="face" fill="url(#gradient)" d="M289.5 1c-24.5 1.5-44.8 5.2-47.7 8.8-1.5 1.8-1.5 21.6.1 29.7.8 4.1.6 5.5-.9 8.5-2.9 5.7-3.4 11.9-1.5 17.8 2 6 8.8 14.4 11 13.5.8-.3 1.5 0 1.5.6s-.5 1.1-1.2 1.1-.6.6.4 1.7c1.3 1.5 1.7 9.8 2.8 53.8l1.2 52-3.1 18c-7.8 45.2-19.6 83.7-48.4 158.5-11.8 30.7-19.7 53.4-19.7 56.2 0 .7 2.5-5.9 5.4-14.7 3-8.8 11-30.4 17.9-48 16.3-41.8 25.2-67.4 32.3-92.3 1.5-5.1 2.9-9 3.1-8.8 1.6 1.6-16.6 57.4-30.3 92.8-15.6 40.3-16.6 43.1-22.5 60.3-3.2 9.3-5.8 15.9-5.9 14.6 0-1.3-.3-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2.5-.3-.6-.5-.1-.5 1.3zM165.1 1132.6c0 1.1.3 1.4.6.6.3-.7.2-1.6-.1-1.9-.3-.4-.6.2-.5 1.3zM484.2 1135c0 1.4.2 1.9.5 1.2.2-.6.2-1.8 0-2.5-.3-.6-.5-.1-.5 1.3zM164.2 1137c0 1.4.2 1.9.5 1.2.2-.6.2-1.8 0-2.5-.3-.6-.5-.1-.5 1.3zM485.1 1139.6c0 1.1.3 1.4.6.6.3-.7.2-1.6-.1-1.9-.3-.4-.6.2-.5 1.3zM163.1 1141.6c0 1.1.3 1.4.6.6.3-.7.2-1.6-.1-1.9-.3-.4-.6.2-.5 1.3zM162.2 1146.5c0 1.6.2 2.2.5 1.2.2-.9.2-2.3 0-3-.3-.6-.5.1-.5 1.8z"/></svg>
Fiddle Link
You need replace from and to attributies to values attribute in the animate tags. Inside values we use decimal numbers. Finally, we make some small changes to the process function to handle our values.
PS. I can't test it in Safari, (I don't have Mac products)
before
<animate class="animatedStop" attributeName="offset" from="0%" to="0%" dur="3s" fill="freeze" begin="0s"/>
after
<animate class="animatedStop" attributeName="offset" values="0;0" dur="3s" fill="freeze" begin="0s"/>
function process(ele) {
if (event.key === 'Enter') {
Array.from(document.getElementsByClassName('animatedStop')).forEach(animation => {
// Get value from input field and divide to get decimal number
const enteredValue = Number(ele.value) / 100;
animation.setAttribute('values', `0;${enteredValue}`);
animation.beginElement();
});
}
}
<div style="float: left">
<label>Enter Value</label>
<input id="fill-color" type="textbox" min="0" max="100" name="fillcolor" value="20" onkeydown="process(this)" />%
</div>
<svg id="octocat" version="1.0" xmlns="http://www.w3.org/2000/svg" width="150" height="450" viewBox="0 0 640 1280">
<defs>
<linearGradient id="gradient" x1="0" y1="100%" x2="0" y2="0">
<stop offset="0%" stop-color="#df1c2a" />
<stop offset="0%" stop-color="#df1c2a">
<animate
class="animatedStop"
attributeName="offset"
values="0;0"
dur="3s"
fill="freeze"
begin="0s"
/>
</stop>
<stop offset="20%" stop-color="black">
<animate
class="animatedStop"
attributeName="offset"
values="0;0"
dur="3s"
fill="freeze"
begin="indefinite"
/>
</stop>
</linearGradient>
</defs>
<path
id="face"
fill="url(#gradient)"
d="M289.5 1c-24.5 1.5-44.8 5.2-47.7 8.8-1.5 1.8-1.5 21.6.1 29.7.8 4.1.6 5.5-.9 8.5-2.9 5.7-3.4 11.9-1.5 17.8 2 6 8.8 14.4 11 13.5.8-.3 1.5 0 1.5.6s-.5 1.1-1.2 1.1-.6.6.4 1.7c1.3 1.5 1.7 9.8 2.8 53.8l1.2 52-3.1 18c-7.8 45.2-19.6 83.7-48.4 158.5-11.8 30.7-19.7 53.4-19.7 56.2 0 .7 2.5-5.9 5.4-14.7 3-8.8 11-30.4 17.9-48 16.3-41.8 25.2-67.4 32.3-92.3 1.5-5.1 2.9-9 3.1-8.8 1.6 1.6-16.6 57.4-30.3 92.8-15.6 40.3-16.6 43.1-22.5 60.3-3.2 9.3-5.8 15.9-5.9 14.6 0-1.3-.3-2.1-.7-1.8-.3.4-.9 6.2-1.3 12.9-.6 10.2-1.2 13.4-3.5 18.8-13.7 32-26.5 140.3-22.7 192.1 1 13.7 4 31.1 5.4 31.7 1.5.7.8 4.8-1.2 6.5-1.8 1.5-2 2.9-2 14.4 0 18.6 3.2 44.5 12 98.3 8.2 49.7 11.4 75.5 14.9 117.5 3.7 43.9 4.4 58.5 3.8 83.5-.6 24.9-1.3 31.7-6.3 57.1-1.4 7.2-2.3 13.3-2.1 13.5.2.2 1.2-3.5 2.2-8.3 2.3-11.7 3.3-15.4 3.4-12.8.2 3.7-4.9 28.5-12.9 63-4.4 18.7-8.5 36.4-9.1 39.3-1.5 6.3-2.6 7.5-2.2 2.4.2-3.4.1-3.4-.8.8-1.5 6.9-.5 35.5 1.5 41l1.6 4.5-3.6-3.9-3.7-3.9.7 3.9c2 11.4 6.6 19 16.5 27.3 10.6 8.8 24.3 13.9 49.6 18.6 20.7 3.8 43.3 5.5 81.5 6.2 84.2 1.4 142.2-6.8 171.2-24.3 6.4-3.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-1.1.2-1.7.5-1.3.3.3.4 1.2.1 1.9zm-317 2c-.3.8-.6.5-.6-.6-.1-1.1.2-1.7.5-1.3.3.3.4 1.2.1 1.9zm320 406.5c-.3 1-.5.4-.5-1.2 0-1.7.2-2.4.5-1.8.2.7.2 2.1 0 3zm4.3 46.3c0 .5-1.9 3.3-4.2 6.1-12 14.6-42.4 24.4-94 30.5-17.9 2.1-103.1 3.1-126.7 1.4-19.7-1.3-36-3.3-49.5-6.1-10.2-2.1-29.1-7.7-28.4-8.5.3-.2 3 .5 6.2 1.6 27.2 9.3 81 14 145.1 12.5 43.2-.9 74.1-4.4 100.1-11 23.4-6 37-12.7 45.4-22.3 4.4-5 6-6.1 6-4.2z"
/>
</svg>

Using for loop to write values to Excel - Python

I have a dataset, and I am trying to use a for loop to scan through all columns and find the max values in each column. Then I am trying to write those max values along with their indices to an excel sheet. When I print the output, I get the values printed, but I cannot write any values to excel sheet. Please find attached my code with the dataset.
import pandas as pd
import numpy as np
import os
import pandas as pd
import numpy as np
import random as rd
import matplotlib.pyplot as plt
from scipy.signal import find_peaks
import plotly.graph_objects as go
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import find_peaks
from scipy.signal import find_peaks, peak_prominences
path = os.path.join('c:' + os.sep, 'Users', 'nsin0029', 'stitching_and_switching', 'eb_iwp_lane_1_radargram.csv')
radargram = pd.read_csv(path).T
print(radargram)
import pandas as pd
for column in radargram:
all_traces = (radargram[column])
maxValues = [all_traces.max()]
index_of_max= [(all_traces.idxmax())]
peakval = pd.DataFrame([maxValues],[index_of_max])
print(index_of_max,maxValues)
writer = pd.ExcelWriter('Book2.xlsx', engine='xlsxwriter')
peakval.to_excel(writer, sheet_name='Sheet 1',index=True)
writer.save()
dataset:
0 1 2 3 4 5 6 7
0 1.0 2.00 3.0 4.00 5.0 6.00 7.0
0.1 0.0 0.05 0.1 0.15 0.2 0.25 0.3
0.117 0.0 -6668751.00 1838.0 -5417580.00 -5570270.0 -5715139.00 -5827291.0
0.156 0.0 -6482365.00 1838.0 -5173158.00 -5293488.0 -5415709.00 -5440243.0
0.195 0.0 -6244235.00 1838.0 -4941067.00 -5016929.0 -5113173.00 -5051908.0
... ... ... ... ... ... ... ...
4.844 0.0 2919134.00 1838.0 297721.00 132719.0 -12214.00 -216.0
4.883 0.0 3181017.00 1838.0 419417.00 210137.0 42928.00 30737.0
4.922 0.0 3322660.00 1838.0 532466.00 288072.0 95415.00 64886.0
4.961 0.0 3342207.00 1838.0 636585.00 356015.0 141400.00 95323.0
5 0.0 3257029.00 1838.0 721372.00 419059.0 185229.00 121306.0
any help would be much appreciated

Strip down SVG to one part of it

I am not very familiar with SVG and was hoping I can filter out a part of an existing SVG. I have the following SVG
<svg xmlns="http://www.w3.org/2000/svg" width="1223" height="331" viewBox="-2 47 1223 331">
<defs>
<clipPath id="a">
<path d="M84.5 208.2c77.3-15 161.7-47.3 237.1-70.1C529.6 81.8 747.8 29.3 962.2 6.4c34-3 72.4-4.4 104.2 9.8 26 11.3 55.5 31.9 80.4 45.2 15.2 8.3 36.4 17.8 47.7 31.6 22 24.8 33.4 63.8 19.7 95.2-44.8 77.5-174.6 122.4-256.8 149.3-86.8 19-180.7 22.3-269.3 22-157.6-3-324.7-17.4-481.4-33.2-28.6-2.3-63-2.1-91.7-.1-19.7.9-54.5 6.2-74.3 3.3l-4.2-1.1c-3.3-1.5-9.7-5.8-12.7-8l-5.5-5.5C1.9 293.5 2 263.4 8.3 238.3l2.5-5 3.6-4.1 4.7-3c20-8.7 44.1-13.8 65.4-18z" />
</clipPath>
<pattern id="b" width="39.37" height="39.37" patternUnits="userSpaceOnUse" patternContentUnits="userSpaceOnUse" viewBox="0 0 100 100">
<path fill="#71CE01" d="M0 0h100v100H0z" />
<path fill="#359200" opacity=".15" d="M0 0h50v100H0z" />
<path fill="#359200" opacity=".15" d="M0 0h100v50H0z" />
</pattern>
</defs>
<g clip-path="url(#a)" transform="rotate(366.63 612 182)">
<path d="M-62-492l1348 0 0 1348-1348 0z" fill="#358806" />
<path d="M1050 142.3a39 39 0 00-9.7-25.3c-1.5-1.6-3.3-3-5.2-4.4-1.9-1.4-4-2.5-6.1-3.4-7.2-3.3-15.3-3.4-23-2.4-7.4.9-14.6 2.5-21.7 4.7-7 2.4-13.8 5.1-20.8 7.4-4 1.3-7.9 2.8-12 3.4-8.7 1.6-17.6.3-26.2-1.6-5.4-1.2-11-2.6-16.6-3-4.7-.5-9.4 0-14.1.1-7.2.2-14.3 1.2-21.5 2-4.9.4-9.8 1.4-14.7 2-5.6.7-11.3 1-17 2-12.4 2.4-24 7.8-36 12-5.2 2-10.4 3.9-15.5 6-5.6 2.3-11.1 4.6-16.8 6.5-7.8 2.5-15.3 5.8-23.2 7.7-5.3 1.4-10.8 2-16.2 2.8-3 .4-6 1-9 1.3-4 .3-8 .4-11.8.5-9 0-18 .4-26.8-1-8.8-1-17.6-2.3-26.4-3.3-3.8-.4-7.7-.8-11.5-1.1-4.7-.3-9.4-.5-14-.6-6.6 0-13 .6-19.6 1.2-6.8.3-13.6 1.7-20.2 3.5-3.5 1-7 2-10.5 3.1-4 1.2-7.8 2.6-11.3 4.7a34 34 0 00-5.3 3.8c-1.6 1.5-3 3.3-4.4 5.1-1.4 1.9-2.9 3.7-4.1 5.7a60 60 0 00-4.7 9.8c-1.3 3.4-2.6 7-3.2 10.6-1 5.8 0 11.8 1.4 17.4 1.4 5 3 9.9 5 14.6a47 47 0 007 11c4 4.6 9 8.5 14.5 11.3 3.6 1.9 7.5 3 11.4 4.3 7 2.4 14.4 2.7 21.7 3.2 4.7.3 9.4.8 14 .6 9.2-.1 18.3-1 27.4-2.2 11.7-1.7 23.4-3.4 34.8-6.6 9.6-2.5 19-5.7 28.4-8.6 8.8-2.4 17.9-3.8 27-3.5 5.3.5 10.6 1.3 16 2 3.7.5 7.5 1.2 11.3 1.6 8.8.5 17.7.4 26.5-.7 4.7-.7 9.4-1.8 14-3.1 5.5-1.9 11-3.8 16.5-5.5 8.4-2.5 16.9-5 25-8.1 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.4 3.4-17 5.9-25.7 8.5-5.3 1.6-10.7 3.4-16 5.3-5.5 1.5-11.2 2.9-17 3.3-6.6.4-13.3.6-20 .2-8.5-1.3-17-2.5-25.7-3.5-4.9-.5-9.8 0-14.7.4-9.7.9-19 3.6-28.2 6.7-8.3 2.6-16.6 5.1-25.1 7-9.3 2.1-18.7 3.6-28.1 4.9-9.4 1-18.8 2-28.3 1.7-4.7-.3-9.5-.5-14.2-1-2.7-.2-5.4-.3-8-.8-2.7-.5-5.3-1.4-8-2.2-2.3-.8-4.7-1.6-7-2.7-5.5-2.8-10.4-7-13.8-12.3a36 36 0 01-4.1-8.9c-1-3-2-6-2.9-8.9-1-4-1.7-8-1-12.2.8-4.1 2.4-8.1 4.1-12 1-1.8 1.8-3.7 3-5.3 1.9-2.5 3.7-5 5.8-7.2 3.1-2.6 6.9-4.3 10.7-5.5z" fill="url(#b)" />
<path d="M264.8 231.8l30.2-3.1 3.2 35-30.5 2.4zm-88.9 9l60-6.6 4.6 41-60.3 6.1zM25 268.4l74.1-9.2 3.4 29-74.1 8.8z" fill="#71ce01" />
<path d="M1141.6 123.6c6.6 7.9 9 23.9 9.9 34 .8 9.5 0 20-7.2 27-1.8 1.8-4 3.2-6.1 4.4-3.1 1.7-6.4 3.2-10 3.6-7.5 1-15-1-21.9-4-5.3-2-10.3-5-14.3-9.1-2.6-2.5-4.1-5.9-4.9-9.3-1-6.1.4-11.6 4.6-16.1 3-3.5 5.8-7 8-11.1 2-4 3.5-8.4 4.6-12.7 1-3.6 1.6-7.3 3.3-10.6 1.3-2.4 3.6-4.2 6-5.4 3.1-1.3 6.6-1.4 9.8-1 6.5 1 14 5.1 18.2 10.3z" fill="#92f100" />
<path d="M1096.2 133.5c-2.2 6-6 11.5-12.2 13.8-4 1.2-8.8.6-12.5-1.7-3-1.9-5.1-4.4-5.8-8-.7-3.1-.7-6.5-1.4-9.7-.6-2.5-1.6-4.9-2.5-7.2-1-2.3-1.4-4.7-1.4-7.2-.1-3.6.9-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.7 1-31-1.2-44.8.5-14.2 2.3-29 7.1-42.4 12.3-6.6 2.5-24 11.5-30.8 13.7-5.7 1.3-12.6 1.8-18.4.4-11-4.9-24.9-12-36.4-15.5-18.7-5.3-39.6-8.6-59-6-17.6 2.5-37 11.8-53.6 18-11.3 4.6-25.2 11.9-37.6 12.3-20.2 1.9-43.5-2.2-63.7-3.4-8 0-31.6 2.2-40 2.9-13 1.2-26.1-3.2-37.8-8.5-6.2-2.6-13-7.9-19.8-9-45.4 4.9-93.3-8.4-138.7-2.7l-3.5 1.3c-4.8 2.2-9.5 7-13.2 10.7-3.6 3.3-9.5 7.2-13.7 9.9-17.7-3.5-50.6-7.1-67.2-13.2-17.7-9.8-16.7-8.6-36.9-9-27.9-2.6-60.2-6.2-80-28.2-18.4-19.9-27.4-54-21.2-80.4-15.2-2-123.3 18.7-140.7 21.4l23.4 125.6c51.4-9.2 112.6-22 164.9-20.5 20.8 5.6 47 6.4 68.4 9 35.4 7.2 80.9 16.5 116 25.5l.7-24.7-2.4-3.3-1-2.2-.2-1.3c0-.9.1-2.5.3-3.3l.4-1.4 1-1.6 1.4-1.3c5.2-3.6 11.9-5.3 18.2-5.6 39.7-1.5 82 7 121.8 3.5l2 .4c34.4 17.4 42.2 19 80.6 15.1 23.9-2 49.4 3.5 73.4 2.5 10.2-.2 21.6-2.2 31-6.2 38.5-15.2 68.3-32.2 111.2-22.4 20.2 3.3 38.2 19.2 58.8 20.3 17.8 1.2 34.5-12 50.8-17.3 12.2-4.3 27.2-9.4 40.2-10.2 12.1-.3 28.6 1.4 40.6-.5 23.7-3.3 54.6-22.7 76.2-32.4 15-7.2 34.4-22.4 49.6-29.2 16.2-6.3 34.2-11.5 51.6-13.6 16.8 0 37.3 2.5 54.1 2.6l6.4-7.6-23.3-1zM84.6 321.8c-3.5.7-13.9 2.4-17.6 3l-.5-.2-.2-.9 0-1.7.4-1.5.7-1.2 1.3-1.3 1.3-.8 1.7-.7c1-.4 3.5-.7 4.6-.8l2.7 0 2.6.7 2.3 1.2.6.5.4.6 0 1.1-.3 2zm48.6-14.5l-1 2.2-1.4 1.8-1.7 1.4-2 1c-1.5.6-26.6 4.4-29 4.8l-.9-.1-.8-.6c-1.3-1.4-6-6.8-7.5-7.8l-2-1.3-2.2-1-2.3-.5-5.8-.6-1.2-8-3.8.4 1.1 8-3.2.7-3.2 1.5-2.7 1.8-2.8 2.7-1.6 2.3-1.3 2.5-1.4 4-.7 4.3-.4.4-.4.2c-5.9 1.2-13.4 2.6-19.4 2.4l-3.3-.7-3-1.1-2.6-1.5-2.4-2-1.5-1.7-1.4-2c-1.4-2.9-2.4-7.2-3-10.2-2.1-14.2-11-55.7-13.8-70.2l0-1 1.2-.3 2.2-.3 2.2 13.6.4.6.5.2c16.8-2 53-9.9 70-13.3l.4-.4.1-.9c-.4-2.9-2-11-1.7-13.9l.3-1 .8-1 1.3-1 1.4-.5 1.7-.4c5.1-.4 10.5 1.8 14.4 5.2.6.6 1.7 2 2.1 2.7l2.3 4.8c.5 11.6 2.5 24.7 7.4 35.2 4.2 11.6 11.8 21.8 20.5 30.3l.7 2 .6 2.9 0 2-.2 1.4z" fill="#b4b4b4" stroke-opacity=".5" stroke="#000" stroke-width=".3" />
</g>
</svg>
Now I would like to filter out one part of the SVG where fill is equal to
"#92f100"
Is it it possible to create a new SVG that only shows the above part?
You might use a simple js query like so:
let filtered = document.querySelectorAll('[fill="#92f100"]');
and then remove these elements
filtered.forEach(function(el,i){
el.remove()
})
let svg = document.querySelector('svg');
let filterColor = '#92f100';
let filtered = svg.querySelectorAll('[fill="' + filterColor + '"]');
//filterOut(filtered);
function filterOut(filtered) {
filtered.forEach(function(el, i) {
el.remove()
})
}
//getFiltered(svg, filtered);
function getFiltered(svg, filtered) {
let defs = svg.querySelector('defs');
svg.innerHTML = '';
svg.appendChild(defs);
filtered.forEach(function(el, i) {
svg.appendChild(el);
})
}
svg {
display: block;
width: 75%
}
<p><button onclick="filterOut(filtered)" type="button">filter out (remove selection)</button>
<button onclick="getFiltered(svg, filtered)" type="button">get filtered (reduce to selection)</button></p>
<svg xmlns="http://www.w3.org/2000/svg" width="1223" height="331" viewBox="-2 47 1223 331">
<defs>
<clipPath id="a">
<path d="M84.5 208.2c77.3-15 161.7-47.3 237.1-70.1C529.6 81.8 747.8 29.3 962.2 6.4c34-3 72.4-4.4 104.2 9.8 26 11.3 55.5 31.9 80.4 45.2 15.2 8.3 36.4 17.8 47.7 31.6 22 24.8 33.4 63.8 19.7 95.2-44.8 77.5-174.6 122.4-256.8 149.3-86.8 19-180.7 22.3-269.3 22-157.6-3-324.7-17.4-481.4-33.2-28.6-2.3-63-2.1-91.7-.1-19.7.9-54.5 6.2-74.3 3.3l-4.2-1.1c-3.3-1.5-9.7-5.8-12.7-8l-5.5-5.5C1.9 293.5 2 263.4 8.3 238.3l2.5-5 3.6-4.1 4.7-3c20-8.7 44.1-13.8 65.4-18z" />
</clipPath>
<pattern id="b" width="39.37" height="39.37" patternUnits="userSpaceOnUse" patternContentUnits="userSpaceOnUse" viewBox="0 0 100 100">
<path fill="#71CE01" d="M0 0h100v100H0z" />
<path fill="#359200" opacity=".15" d="M0 0h50v100H0z" />
<path fill="#359200" opacity=".15" d="M0 0h100v50H0z" />
</pattern>
</defs>
<g clip-path="url(#a)" transform="rotate(366.63 612 182)">
<path d="M-62-492l1348 0 0 1348-1348 0z" fill="#358806" />
<path d="M1050 142.3a39 39 0 00-9.7-25.3c-1.5-1.6-3.3-3-5.2-4.4-1.9-1.4-4-2.5-6.1-3.4-7.2-3.3-15.3-3.4-23-2.4-7.4.9-14.6 2.5-21.7 4.7-7 2.4-13.8 5.1-20.8 7.4-4 1.3-7.9 2.8-12 3.4-8.7 1.6-17.6.3-26.2-1.6-5.4-1.2-11-2.6-16.6-3-4.7-.5-9.4 0-14.1.1-7.2.2-14.3 1.2-21.5 2-4.9.4-9.8 1.4-14.7 2-5.6.7-11.3 1-17 2-12.4 2.4-24 7.8-36 12-5.2 2-10.4 3.9-15.5 6-5.6 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.5-3 4.8-5.2 6.7a53.2 53.2 0 01-9.2 7.5c-5 3-10.6 5.1-16.3 6.7-5.4 1.7-11.2 2.2-16.9 2.4-6.4.4-13 .7-19.4 1.4-3.2.4-6.3 1.6-9.4 2.8-3 1.2-5.9 2.4-8.5 4.2-6 3.8-11.4 9-18.4 11-4.6 1.3-9.3 1.6-14 1.6-6.2.1-12.5.2-18.6 1-5 .7-9.8 2.4-14.6 4-11.8 4-23 9.6-34.2 14.8-10.2 4.5-21 7.4-31.7 10.7-4.6 1.4-9.3 3-13.9 4.6a123 123 0 01-10.2 2.5c-5.8 1.2-11.9 1.4-17.9 1.6-4.6 0-9.2.1-13.8-.6a442 442 0 00-25-3.3c-5-.3-10.1.3-15 .9-8.6 1-16.8 3.8-24.9 6.5a464.7 464.7 0 01-20.2 5.8c-7.2 1.8-14.6 3-22 4.2-9.8 1.6-19.7 3-29.6 3.3-6.5.4-13 .1-19.6-.4-4.6-.4-9.3-.5-13.9-1.3-3.1-.5-6.2-1.5-9.2-2.5-2.7-1-5.4-1.8-8-3-8.1-4.2-15-11-19-19.3-1.2-2.6-2-5.5-3-8.2-1.8-5.1-3.3-10.4-3.6-15.8-.4-5 1-9.8 2.8-14.3 1.3-3.7 3-7.2 5-10.5a97 97 0 015.8-7.7c1.6-2 3.6-3.4 5.8-4.7 4-2.6 8.7-3.8 13.2-5.3 8-2.3 16.2-4.8 24.6-5.3 8-.6 16-1.7 24.1-1.3 18 .3 35.8 3.4 53.7 5.5 5.2.5 10.4.5 15.6.4 5.9 0 11.8 0 17.7-.4 4.3-.4 8.7-1.2 13-1.8 4.4-.7 9-1.2 13.3-2.3 5.9-1.3 11.5-3.4 17-5.5 6-2 12-4 17.7-6.3 10.2-4.3 20.5-8.2 30.8-12 7.8-2.9 15.6-6 23.7-8 6-1.4 12.3-1.6 18.4-2.3 5.6-.7 11.2-1.9 16.9-2.4 8.4-1 17-1.8 25.5-2 6.8-.5 13.5.5 20 2 10.3 2.4 20.8 4.5 31.3 2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9c-1-3-2-6-2.9-8.9-1-4-1.7-8-1-12.2.8-4.1 2.4-8.1 4.1-12 1-1.8 1.8-3.7 3-5.3 1.9-2.5 3.7-5 5.8-7.2 3.1-2.6 6.9-4.3 10.7-5.5z" fill="url(#b)" />
<path d="M264.8 231.8l30.2-3.1 3.2 35-30.5 2.4zm-88.9 9l60-6.6 4.6 41-60.3 6.1zM25 268.4l74.1-9.2 3.4 29-74.1 8.8z" fill="#71ce01" />
<path d="M1141.6 123.6c6.6 7.9 9 23.9 9.9 34 .8 9.5 0 20-7.2 27-1.8 1.8-4 3.2-6.1 4.4-3.1 1.7-6.4 3.2-10 3.6-7.5 1-15-1-21.9-4-5.3-2-10.3-5-14.3-9.1-2.6-2.5-4.1-5.9-4.9-9.3-1-6.1.4-11.6 4.6-16.1 3-3.5 5.8-7 8-11.1 2-4 3.5-8.4 4.6-12.7 1-3.6 1.6-7.3 3.3-10.6 1.3-2.4 3.6-4.2 6-5.4 3.1-1.3 6.6-1.4 9.8-1 6.5 1 14 5.1 18.2 10.3z" fill="#92f100" />
<path d="M1096.2 133.5c-2.2 6-6 11.5-12.2 13.8-4 1.2-8.8.6-12.5-1.7-3-1.9-5.1-4.4-5.8-8-.7-3.1-.7-6.5-1.4-9.7-.6-2.5-1.6-4.9-2.5-7.2-1-2.3-1.4-4.7-1.4-7.2-.1-3.6.9-7.6 3.4-10.3 3.3-3.2 8.4-2.4 12.5-1.7 7.7 1.6 13.6 2.9 18.3 9.7 4.5 6.5 4.4 15.2 1.6 22.3zm-30.3 62.2c-2.6 6.6-7.6 11.5-15.1 9.8-4-.8-7.7-3.3-10-6.7-2-4-2-9.3-.8-13.6.3-1.7 1.4-3.1 2.6-4.5 1-1.3 2.2-2.8 3.4-4 4.8-4.6 12-8.7 18.8-8.4 5.2.6 11.5 2.7 13 8.2.7 2.5.3 5.3-1 7.5-.6 1.4-1.4 2.8-2.9 3.4-6 2.5-5.6 2.3-8 8.3zm-79.8 23a57 57 0 00-2.7 8.7c-.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8-23.4-4.5-.3-3.5-1.2-7-1.6-10.5-.2-2-.8-4.6 1-6.1 4.1-3.4 10.4-1.8 14.6.4 4.6 2 7 6 8.7 10.4zM79 322.8c-3 .6-6 1-9 1.5-1.2.1-2.3.5-3.5.5l-.1-.1c-.4-1-.2-2-.1-3 .2-1.9 1.7-3.4 3.2-4.3 3.4-1.7 7.7-2.3 11.3-1.2 1.5.5 3.2 1.1 4 2.5.3 1 0 2-.2 3-1.8.5-3.8.7-5.6 1zm130.6-13.2c-5.7-1-11.4-1.7-17-3-9.8-2.4-19.4-5.7-28-11 1.6-1 3.2-1.8 5-1.9 3.8-.1 7.5.6 11.2 1 10.8 1.3 21.7 2 32.6 3 15.5 1.3 31.2.7 46.7-1 8.6-1.1 13.1-.1 16.2 8.7a52 52 0 012.3 10c.5 3 .2 6-1.2 8.7-4.2-1-8.4-2.2-12.3-4.1-3-1.5-5.6-3.5-8.6-4.9a27.8 27.8 0 00-10.3-2.6c-5.8-.4-11.7-.2-17.5-.6-6.4-.3-12.8-1.2-19.1-2.3z" fill="#b58254" />
<path d="M1205 223.9c-13.5-.9-32.7-3.6-46-1.3-18 3.7-37.4 9-54.2 16.5-4.6 2.4-11.4 7.4-15.6 10.6-9.1 6.3-20.6 13-30.5 17.9-15.9 8-35.8 17.6-51.8 25.2-5.7 2.4-12.4 4.3-18.6 4.6-13.7 1-31-1.2-44.8.5-14.2 2.3-29 7.1-42.4 12.3-6.6 2.5-24 11.5-30.8 13.7-5.7 1.3-12.6 1.8-18.4.4-11-4.9-24.9-12-36.4-15.5-18.7-5.3-39.6-8.6-59-6-17.6 2.5-37 11.8-53.6 18-11.3 4.6-25.2 11.9-37.6 12.3-20.2 1.9-43.5-2.2-63.7-3.4-8 0-31.6 2.2-40 2.9-13 1.2-26.1-3.2-37.8-8.5-6.2-2.6-13-7.9-19.8-9-45.4 4.9-93.3-8.4-138.7-2.7l-3.5 1.3c-4.8 2.2-9.5 7-13.2 10.7-3.6 3.3-9.5 7.2-13.7 9.9-17.7-3.5-50.6-7.1-67.2-13.2-17.7-9.8-16.7-8.6-36.9-9-27.9-2.6-60.2-6.2-80-28.2-18.4-19.9-27.4-54-21.2-80.4-15.2-2-123.3 18.7-140.7 21.4l23.4 125.6c51.4-9.2 112.6-22 164.9-20.5 20.8 5.6 47 6.4 68.4 9 35.4 7.2 80.9 16.5 116 25.5l.7-24.7-2.4-3.3-1-2.2-.2-1.3c0-.9.1-2.5.3-3.3l.4-1.4 1-1.6 1.4-1.3c5.2-3.6 11.9-5.3 18.2-5.6 39.7-1.5 82 7 121.8 3.5l2 .4c34.4 17.4 42.2 19 80.6 15.1 23.9-2 49.4 3.5 73.4 2.5 10.2-.2 21.6-2.2 31-6.2 38.5-15.2 68.3-32.2 111.2-22.4 20.2 3.3 38.2 19.2 58.8 20.3 17.8 1.2 34.5-12 50.8-17.3 12.2-4.3 27.2-9.4 40.2-10.2 12.1-.3 28.6 1.4 40.6-.5 23.7-3.3 54.6-22.7 76.2-32.4 15-7.2 34.4-22.4 49.6-29.2 16.2-6.3 34.2-11.5 51.6-13.6 16.8 0 37.3 2.5 54.1 2.6l6.4-7.6-23.3-1zM84.6 321.8c-3.5.7-13.9 2.4-17.6 3l-.5-.2-.2-.9 0-1.7.4-1.5.7-1.2 1.3-1.3 1.3-.8 1.7-.7c1-.4 3.5-.7 4.6-.8l2.7 0 2.6.7 2.3 1.2.6.5.4.6 0 1.1-.3 2zm48.6-14.5l-1 2.2-1.4 1.8-1.7 1.4-2 1c-1.5.6-26.6 4.4-29 4.8l-.9-.1-.8-.6c-1.3-1.4-6-6.8-7.5-7.8l-2-1.3-2.2-1-2.3-.5-5.8-.6-1.2-8-3.8.4 1.1 8-3.2.7-3.2 1.5-2.7 1.8-2.8 2.7-1.6 2.3-1.3 2.5-1.4 4-.7 4.3-.4.4-.4.2c-5.9 1.2-13.4 2.6-19.4 2.4l-3.3-.7-3-1.1-2.6-1.5-2.4-2-1.5-1.7-1.4-2c-1.4-2.9-2.4-7.2-3-10.2-2.1-14.2-11-55.7-13.8-70.2l0-1 1.2-.3 2.2-.3 2.2 13.6.4.6.5.2c16.8-2 53-9.9 70-13.3l.4-.4.1-.9c-.4-2.9-2-11-1.7-13.9l.3-1 .8-1 1.3-1 1.4-.5 1.7-.4c5.1-.4 10.5 1.8 14.4 5.2.6.6 1.7 2 2.1 2.7l2.3 4.8c.5 11.6 2.5 24.7 7.4 35.2 4.2 11.6 11.8 21.8 20.5 30.3l.7 2 .6 2.9 0 2-.2 1.4z" fill="#b4b4b4" stroke-opacity=".5" stroke="#000" stroke-width=".3" />
</g>
</svg>

xarray too slow for performance critical code

I planned to use xarray extensively in some numerically intensive scientific code that I am writing. So far, it makes the code very elegant, but I think I will have to abandon it as the performance cost is far too high.
Here is an example, which creates two arrays and multiplies parts of them together using xarray (with several indexing schemes), and numpy. I used num_comp=2 and num_x=10000:
Line # Hits Time Per Hit % Time Line Contents
4 #profile
5 def xr_timing(num_comp, num_x):
6 1 4112 4112.0 10.1 da1 = xr.DataArray(np.random.random([num_comp, num_x]).astype(np.float32), dims=['component', 'x'], coords={'component': ['a', 'b'], 'x': np.linspace(0, 1, num_x)})
7 1 438 438.0 1.1 da2 = da1.copy()
8 1 1398 1398.0 3.4 da2[:] = np.random.random([num_comp, num_x]).astype(np.float32)
9 1 7148 7148.0 17.6 da3 = da1.isel(component=0).drop('component') * da2.isel(component=0).drop('component')
10 1 6298 6298.0 15.5 da4 = da1[dict(component=0)].drop('component') * da2[dict(component=0)].drop('component')
11 1 7541 7541.0 18.6 da5 = da1.sel(component='a').drop('component') * da2.sel(component='a').drop('component')
12 1 7184 7184.0 17.7 da6 = da1.loc[dict(component='a')].drop('component') * da2.loc[dict(component='a')].drop('component')
13 1 6479 6479.0 16.0 da7 = da1[0, :].drop('component') * da2[0, :].drop('component')
15 #profile
16 def np_timing(num_comp, num_x):
17 1 1027 1027.0 50.2 da1 = np.random.random([num_comp, num_x]).astype(np.float32)
18 1 977 977.0 47.8 da2 = np.random.random([num_comp, num_x]).astype(np.float32)
19 1 41 41.0 2.0 da3 = da1[0, :] * da2[0, :]
The fastest xarray multiplication takes about 150X the time of the numpy version. This is just one of the operations in my code, but I find most of them are many times slower than the numpy equivalent, which is unfortunate as xarray makes the code so much clearer. Am I doing something wrong?
Update: Even da1[0, :].values * da2[0, :].values (which loses many of the benefits of using xarray) takes 2464 time units.
I am using xarray 0.9.6, pandas 0.21.0, numpy 1.13.3, and Python 3.5.2.
Update 2:
As requested by #Maximilian, here is a re-run with num_x=1000000:
Line # Hits Time Per Hit % Time Line Contents
# xarray
9 5 408596 81719.2 11.3 da3 = da1.isel(component=0).drop('component') * da2.isel(component=0).drop('component')
10 5 407003 81400.6 11.3 da4 = da1[dict(component=0)].drop('component') * da2[dict(component=0)].drop('component')
11 5 411248 82249.6 11.4 da5 = da1.sel(component='a').drop('component') * da2.sel(component='a').drop('component')
12 5 411730 82346.0 11.4 da6 = da1.loc[dict(component='a')].drop('component') * da2.loc[dict(component='a')].drop('component')
13 5 406757 81351.4 11.3 da7 = da1[0, :].drop('component') * da2[0, :].drop('component')
14 5 48800 9760.0 1.4 da8 = da1[0, :].values * da2[0, :].values
# numpy
20 5 37476 7495.2 2.9 da3 = da1[0, :] * da2[0, :]
The performance difference has decreased substantially, as expected (only about 10X slower now), but I am still glad that the issue will be mentioned in the next release of the documentation as even this amount of difference may surprise some people.
Yes, this is a known limitation for xarray. Performance sensitive code that uses small arrays is much slower for xarray than NumPy. I wrote a new section about this in our docs for the next version:
http://xarray.pydata.org/en/stable/computation.html#wrapping-custom-computation
You basically have two options:
Write your performance sensitive code on unwrapped arrays, and then wrap them back in xarray data structures. Xarray v0.10 has a new helper function (apply_ufunc) that makes this a little easier. See the link above if you are interested in this.
Use something other than xarray/Python to do your computation. This could also make sense because Python itself adds significant overhead. Julia's AxisArrays.jl looks like interesting, though I haven't tried it myself.
I suppose option 3 would be to rewrite xarray itself in C++ (e.g., on top of xtensor), but that would be much more involved!

Resources