-
Notifications
You must be signed in to change notification settings - Fork 9
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
Apply the same scale bar / scaling to multiple phylograms #41
Comments
Hi! This is possible with a short custom script.
Click to expand source codeusing PhyloTree;
using System.Collections.Generic;
using TreeViewer;
using VectSharp;
namespace ab61f97f546704f82b5be4f3ffcd77665
{
//Do not change class name
public static class CustomCoordinates
{
//Do not change method signature
public static void GetCoordinates(TreeNode tree, ref Dictionary<string, Point> coordinates)
{
// This parameter determines the final size of the tree. Make it bigger/smaller as you see fit.
double targetScale = 10;
// You should not need to change anything further.
// The current scaling factor for converting branch length units to graphics units.
double currentScale = coordinates["95b61284-b870-48b9-b51c-3276f7d89df1"].X;
// Create a new dictionary to hold the rescaled coordinates.
Dictionary<string, Point> scaledCoordinates = new Dictionary<string, Point>();
// Cycle through all the coordinates.
foreach (KeyValuePair<string, Point> kvp in coordinates)
{
// Rescale the coordinates of every point by a factor of targetScale / currentScale.
scaledCoordinates[kvp.Key] = new Point(kvp.Value.X / currentScale * targetScale, kvp.Value.Y / currentScale * targetScale);
}
// Use the new scaledCoordinates dictionary in place of the previous coordinates.
coordinates = scaledCoordinates;
}
}
} You should follow these steps for all the trees you want to plot, and this will ensure that they all have the same scaling. You can then use the Scale bar Plot action module only on one of them. To determine the actual size of the trees, you can change the value of the I hope this works, let me know if you have any more questions! |
I have several unrooted phylograms that I would like to present in the same figure, all with the same scaling/scale bar. Is this possible? At the moment I have several phylograms, each with a different scale bar.
Many thanks!
The text was updated successfully, but these errors were encountered: