我已经使用JAXB生成了XML
def plot_city(city_name, data):
""" generate plot for one city """
measures = {
'petal width (cm)': 'tab:orange',
'sepal width (cm)': 'tab:blue',
}
line_styles = {
'before': '--',
'after': '-',
}
fig, ax = plt.subplots(figsize=(12, 9))
for measure, colour in measures.items():
for period, group in data.groupby('period'):
sns.distplot(
ax=ax,
a=group[measure],
hist=False,
label=f'petal: {period}',
color=colour,
kde_kws={'linestyle':line_styles[period]}
)
ax.set_title(city_name, fontsize=24)
ax.set_xlabel('width (cm)', fontsize=18)
plt.legend(fontsize=18)
return fig
for city_name, data in df.groupby('city'):
fig = plot_city(city_name, data)
fig.savefig(f'./{city_name}.png', bbox_inches='tight')
plt.show()
当我进行解组时,仅正确创建了最后一个CHILD。所有其他均为空。我不知道为什么会这样。我怀疑问题是对象SIM作为属性传递。
这是它的配置方式:
<relationships>
<relationship>
<id>1</id>
<type>NEUTRAL</type>
<current>false</current>
<children>
<child sim="1" isAdopted="false"/>
</children>
</relationship>
<relationship>
<id>2</id>
<type>NEUTRAL</type>
<current>false</current>
<children>
<child sim="2" isAdopted="false"/>
</children>
</relationship>
<relationship>
<id>4</id>
<type>LOVE</type>
<current>true</current>
<simLeft>2</simLeft>
<simRight>1</simRight>
<children>
<child sim="3" isAdopted="false"/>
</children>
</relationship>
儿童班:
@XmlElementWrapper(name = "children")
@XmlElements({@XmlElement(name = "child", type = Child.class)})
private ObservableList<Child> children = FXCollections.observableArrayList();