Skip to content

Commit

Permalink
Merge pull request #58 from GComitini/fix-no-legend
Browse files Browse the repository at this point in the history
Do not include legend box if there is no legend
Axect authored Apr 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 44a4ea1 + 2695b0e commit e13f060
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/util/plot.rs
Original file line number Diff line number Diff line change
@@ -651,10 +651,14 @@ impl Plot for Plot2D {
}
}

if !legends.is_empty() {
plot_string.push_str("plt.legend()\n");
}

if self.tight {
plot_string.push_str(&format!("plt.legend()\nplt.savefig(pa, dpi={}, bbox_inches='tight')", dpi)[..]);
plot_string.push_str(&format!("plt.savefig(pa, dpi={}, bbox_inches='tight')", dpi)[..]);
} else {
plot_string.push_str(&format!("plt.legend()\nplt.savefig(pa, dpi={})", dpi)[..]);
plot_string.push_str(&format!("plt.savefig(pa, dpi={})", dpi)[..]);
}

py.run(&plot_string[..], Some(&globals), None)?;

0 comments on commit e13f060

Please sign in to comment.