-
Notifications
You must be signed in to change notification settings - Fork 0
Enhance x-tick label customization: add font size, color, and rotatio… #2
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,9 @@ def plot_peptigram( | |
| title: Optional[str] = None, | ||
| x_lab_forntsize: int = 12, | ||
| y_lab_forntsize: int = 12, | ||
| xticks_font: int = 12, | ||
| xticks_color: str = "#333333", | ||
| xticks_rotation: int = 0, | ||
|
Comment on lines
+53
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Parameter naming is inconsistent between function signature and docstring. The docstring uses 'x_ticks_rotation' while the parameter is 'xticks_rotation'. Please use the same name in both for clarity. Suggested implementation: x_ticks_rotation: int = 0, """
Create a PeptiGram visualization with protein-based coloring.
Font size for x-axis labels Amino acid positions(default: 12)
x_ticks_rotation: int
Rotation angle for x-axis tick labels (default: 0) # ... (usage in function body)
ax.set_xticklabels(labels, fontsize=xticks_font, color=xticks_color, rotation=x_ticks_rotation) |
||
| annotate: bool = True, | ||
| min_intensity: Optional[float] = None, | ||
| highlight_regions: Optional[List[Tuple[int, int]]] = None, | ||
|
|
@@ -65,7 +68,7 @@ def plot_peptigram( | |
| highlight_alpha: float = 0.25, | ||
| highlight_color: str = "#FF8888", | ||
| dpi: int = 300 | ||
| ): | ||
| ) -> Tuple[plt.Figure, List[plt.Axes]]: | ||
| """ | ||
| Create a PeptiGram visualization with protein-based coloring. | ||
|
|
||
|
|
@@ -87,6 +90,12 @@ def plot_peptigram( | |
| Font size for x-axis labels Amino acid positions(default: 12) | ||
| y_lab_forntsize : int, optional | ||
| Font size for y-axis labels Sample names and Density plot(default: 12) | ||
| xticks_font : int, optional | ||
| Font size for x-axis tick labels (default: 12) | ||
| xticks_color : str, optional | ||
| Color for x-axis tick labels (default: "#333333") | ||
| x_ticks_rotation : int, optional | ||
| Rotation angle for x-axis tick labels (default: 0) | ||
| annotate : bool, optional | ||
| Whether to annotate proteins (default: True) | ||
| min_intensity : float, optional | ||
|
|
@@ -315,7 +324,7 @@ def plot_peptigram( | |
| # Get color for this protein | ||
| protein_color = protein_to_color[protein_id] | ||
|
|
||
| # Plot density with publication-quality styling | ||
| # Plot density with high quality styling | ||
| axs[0].bar(positions, density, color=protein_color, alpha=0.75, width=1, | ||
| label=protein_id, edgecolor=None, linewidth=0) | ||
|
|
||
|
|
@@ -537,7 +546,7 @@ def plot_peptigram( | |
| space_needed = spaces[height, space_start:space_end+1] | ||
| if np.sum(space_needed) == 0: # Space is available | ||
| spaces[height, space_start:space_end+1] = 1 | ||
| # Publication-quality peptide visualization | ||
| #peptide visualization | ||
| ax.plot( | ||
| [start, end], | ||
| [-height-0.4, -height-0.4], | ||
|
|
@@ -586,7 +595,6 @@ def plot_peptigram( | |
| linestyle='-', alpha=0.3, linewidth=0.8) | ||
| ax.axvline(end, color=highlight_color, | ||
| linestyle='-', alpha=0.3, linewidth=0.8) | ||
|
|
||
| # Set title | ||
| if title is None: | ||
| if len(protein_ids) == 1: | ||
|
|
@@ -604,7 +612,7 @@ def plot_peptigram( | |
| protein_str = protein_str[:47] + "..." | ||
| plt.figtext(0.5, 0.94, protein_str, ha='center', color=text_color, | ||
| fontsize=9, fontstyle='italic') | ||
|
|
||
| # Add subtitle for coloring method | ||
| coloring_method = "" | ||
| if color_by_protein_and_intensity: | ||
|
|
@@ -635,6 +643,16 @@ def plot_peptigram( | |
| plt.figtext(0.5, y_pos, f"Auto-highlighted regions: {regions_str}", | ||
| ha='center', fontsize=9, fontstyle='italic', color=highlight_color) | ||
|
|
||
| # Handle x-tick labels for all axes except the last one | ||
| for i in range(len(axs)): | ||
| # if i == 0: # Density plot - keep labels | ||
| # continue | ||
| if i == len(axs) - 1: # Last plot - keep labels | ||
| axs[i].tick_params(axis='x', labelsize=xticks_font, rotation=xticks_rotation, labelcolor=xticks_color) | ||
| else: # Middle plots - hide labels | ||
| axs[i].tick_params(axis='x', labelbottom=False) | ||
|
|
||
|
|
||
| # Set x-label on the bottom axis only | ||
| axs[-1].set_xlabel('Amino Acid Position', | ||
| fontweight='normal', color=text_color, fontsize=x_lab_forntsize) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick (typo): Title spelling is inconsistent with US/UK English conventions.
Consider updating the spelling to match the convention used elsewhere in the project.