Join a list of numbers into a string, maintain overall spacing between elements and charactersNicest way to pad zeroes to a stringPython join: why is it string.join(list) instead of list.join(string)?Count the number of occurrences of a character in a string in JavascriptCount the number occurrences of a character in a stringThe difference between bracket [] and double bracket [[]] for accessing the elements of a list or dataframeHow do I get the number of elements in a list in Python?Join a list of items with different types as string in PythonConvert a list of characters into a stringRemoving a list of characters in stringPython - Create list with numbers between 2 values?Text on a plot: Align so characters match (formatted string from a list of numbers)
Do Legal Documents Require Signing In Standard Pen Colors?
Diode in opposite direction?
Engineer refusing to file/disclose patents
Flux received by a negative charge
What (else) happened July 1st 1858 in London?
Do the concepts of IP address and network interface not belong to the same layer?
How much character growth crosses the line into breaking the character
Longest common substring in linear time
What's the difference between 違法 and 不法?
We have a love-hate relationship
How do I repair my stair bannister?
Proving a function is onto where f(x)=|x|.
Is camera lens focus an exact point or a range?
Varistor? Purpose and principle
MAXDOP Settings for SQL Server 2014
Why did the HMS Bounty go back to a time when whales are already rare?
Is it possible to have a strip of cold climate in the middle of a planet?
Will adding a BY-SA image to a blog post make the entire post BY-SA?
About a little hole in Z'ha'dum
Are lightweight LN wallets vulnerable to transaction withholding?
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
How to align and center standalone amsmath equations?
Folder comparison
A social experiment. What is the worst that can happen?
Join a list of numbers into a string, maintain overall spacing between elements and characters
Nicest way to pad zeroes to a stringPython join: why is it string.join(list) instead of list.join(string)?Count the number of occurrences of a character in a string in JavascriptCount the number occurrences of a character in a stringThe difference between bracket [] and double bracket [[]] for accessing the elements of a list or dataframeHow do I get the number of elements in a list in Python?Join a list of items with different types as string in PythonConvert a list of characters into a stringRemoving a list of characters in stringPython - Create list with numbers between 2 values?Text on a plot: Align so characters match (formatted string from a list of numbers)
I am working with a list of numbers, where each single digit number has been formatted to have 2 characters, i.e. ' 9', '20', ' 1' and etc.
My issue is when I turn the list into a string, via str.join, the new string keeps the spacing correct when I print, but for plotting it doesn't. I could just add a leading zero to keep the integrity, but for aesthetic purposes I want to keep single digit numbers.
I have 2 of these lists that have been converted to strings, with different numbers, so when they vary, they start to stray from one another. Is it possible to keep the spacing integrity like print does, for plotting text.
The text prints like this (spacing perfect, same width):
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
But plots like this (where the overall spacing and width is off).
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
I am aware of using spacing between characters in join, but here is some of my code:
q = [1, 3, 4, 2, 2, 4, 4, 2, 1, 1, 1, 1, 1, 1, 6, 14, 11, 16, 16, 10, 5, 4, 3, 3, 6]
q1 = [2, 4, 4, 4, 3, 5, 5, 3, 1, 2, 1, 1, 1, 3, 14, 18, 13, 21, 20, 12, 10, 6, 4, 4, 8]
ddd = [':2'.format(x) for x in q]
dddd = [':2'.format(x) for x in q1]
q3 = " ".join([':>2'.format(x) for x in ddd])
q4 = " ".join([':>2'.format(x) for x in dddd])
Pic for reference
Plotting text code:
ax.text(0.035, 0.97, q3, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
ax.text(0.035, 0.92, q4, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
python string list join plot
|
show 1 more comment
I am working with a list of numbers, where each single digit number has been formatted to have 2 characters, i.e. ' 9', '20', ' 1' and etc.
My issue is when I turn the list into a string, via str.join, the new string keeps the spacing correct when I print, but for plotting it doesn't. I could just add a leading zero to keep the integrity, but for aesthetic purposes I want to keep single digit numbers.
I have 2 of these lists that have been converted to strings, with different numbers, so when they vary, they start to stray from one another. Is it possible to keep the spacing integrity like print does, for plotting text.
The text prints like this (spacing perfect, same width):
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
But plots like this (where the overall spacing and width is off).
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
I am aware of using spacing between characters in join, but here is some of my code:
q = [1, 3, 4, 2, 2, 4, 4, 2, 1, 1, 1, 1, 1, 1, 6, 14, 11, 16, 16, 10, 5, 4, 3, 3, 6]
q1 = [2, 4, 4, 4, 3, 5, 5, 3, 1, 2, 1, 1, 1, 3, 14, 18, 13, 21, 20, 12, 10, 6, 4, 4, 8]
ddd = [':2'.format(x) for x in q]
dddd = [':2'.format(x) for x in q1]
q3 = " ".join([':>2'.format(x) for x in ddd])
q4 = " ".join([':>2'.format(x) for x in dddd])
Pic for reference
Plotting text code:
ax.text(0.035, 0.97, q3, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
ax.text(0.035, 0.92, q4, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
python string list join plot
What do you mean by plotting text?
– FChm
Mar 7 at 9:14
Possible duplicate of Nicest way to pad zeroes to a string
– meowgoesthedog
Mar 7 at 9:33
plotting text with plt.text over a graph. i've added a pic to help
– user279955
Mar 7 at 9:34
I've looked into padding with zeroes. It makes it even, but I don't want leading zeroes.
– user279955
Mar 7 at 9:36
@user279955 Can you show us the code you use to make the plot (or at least the code which adds the text to the plot) ?
– Ralf
Mar 7 at 9:55
|
show 1 more comment
I am working with a list of numbers, where each single digit number has been formatted to have 2 characters, i.e. ' 9', '20', ' 1' and etc.
My issue is when I turn the list into a string, via str.join, the new string keeps the spacing correct when I print, but for plotting it doesn't. I could just add a leading zero to keep the integrity, but for aesthetic purposes I want to keep single digit numbers.
I have 2 of these lists that have been converted to strings, with different numbers, so when they vary, they start to stray from one another. Is it possible to keep the spacing integrity like print does, for plotting text.
The text prints like this (spacing perfect, same width):
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
But plots like this (where the overall spacing and width is off).
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
I am aware of using spacing between characters in join, but here is some of my code:
q = [1, 3, 4, 2, 2, 4, 4, 2, 1, 1, 1, 1, 1, 1, 6, 14, 11, 16, 16, 10, 5, 4, 3, 3, 6]
q1 = [2, 4, 4, 4, 3, 5, 5, 3, 1, 2, 1, 1, 1, 3, 14, 18, 13, 21, 20, 12, 10, 6, 4, 4, 8]
ddd = [':2'.format(x) for x in q]
dddd = [':2'.format(x) for x in q1]
q3 = " ".join([':>2'.format(x) for x in ddd])
q4 = " ".join([':>2'.format(x) for x in dddd])
Pic for reference
Plotting text code:
ax.text(0.035, 0.97, q3, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
ax.text(0.035, 0.92, q4, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
python string list join plot
I am working with a list of numbers, where each single digit number has been formatted to have 2 characters, i.e. ' 9', '20', ' 1' and etc.
My issue is when I turn the list into a string, via str.join, the new string keeps the spacing correct when I print, but for plotting it doesn't. I could just add a leading zero to keep the integrity, but for aesthetic purposes I want to keep single digit numbers.
I have 2 of these lists that have been converted to strings, with different numbers, so when they vary, they start to stray from one another. Is it possible to keep the spacing integrity like print does, for plotting text.
The text prints like this (spacing perfect, same width):
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
But plots like this (where the overall spacing and width is off).
1 3 4 2 2 4 4 2 1 1 1 1 1 1 6 14 11 16 16 10 5 4 3 3 6
2 4 4 4 3 5 5 3 1 2 1 1 1 3 14 18 13 21 20 12 10 6 4 4 8
I am aware of using spacing between characters in join, but here is some of my code:
q = [1, 3, 4, 2, 2, 4, 4, 2, 1, 1, 1, 1, 1, 1, 6, 14, 11, 16, 16, 10, 5, 4, 3, 3, 6]
q1 = [2, 4, 4, 4, 3, 5, 5, 3, 1, 2, 1, 1, 1, 3, 14, 18, 13, 21, 20, 12, 10, 6, 4, 4, 8]
ddd = [':2'.format(x) for x in q]
dddd = [':2'.format(x) for x in q1]
q3 = " ".join([':>2'.format(x) for x in ddd])
q4 = " ".join([':>2'.format(x) for x in dddd])
Pic for reference
Plotting text code:
ax.text(0.035, 0.97, q3, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
ax.text(0.035, 0.92, q4, horizontalalignment='left',
verticalalignment='baseline', fontsize=9.5, transform=ax.transAxes)
python string list join plot
python string list join plot
edited Mar 7 at 9:59
user279955
asked Mar 7 at 9:12
user279955user279955
186
186
What do you mean by plotting text?
– FChm
Mar 7 at 9:14
Possible duplicate of Nicest way to pad zeroes to a string
– meowgoesthedog
Mar 7 at 9:33
plotting text with plt.text over a graph. i've added a pic to help
– user279955
Mar 7 at 9:34
I've looked into padding with zeroes. It makes it even, but I don't want leading zeroes.
– user279955
Mar 7 at 9:36
@user279955 Can you show us the code you use to make the plot (or at least the code which adds the text to the plot) ?
– Ralf
Mar 7 at 9:55
|
show 1 more comment
What do you mean by plotting text?
– FChm
Mar 7 at 9:14
Possible duplicate of Nicest way to pad zeroes to a string
– meowgoesthedog
Mar 7 at 9:33
plotting text with plt.text over a graph. i've added a pic to help
– user279955
Mar 7 at 9:34
I've looked into padding with zeroes. It makes it even, but I don't want leading zeroes.
– user279955
Mar 7 at 9:36
@user279955 Can you show us the code you use to make the plot (or at least the code which adds the text to the plot) ?
– Ralf
Mar 7 at 9:55
What do you mean by plotting text?
– FChm
Mar 7 at 9:14
What do you mean by plotting text?
– FChm
Mar 7 at 9:14
Possible duplicate of Nicest way to pad zeroes to a string
– meowgoesthedog
Mar 7 at 9:33
Possible duplicate of Nicest way to pad zeroes to a string
– meowgoesthedog
Mar 7 at 9:33
plotting text with plt.text over a graph. i've added a pic to help
– user279955
Mar 7 at 9:34
plotting text with plt.text over a graph. i've added a pic to help
– user279955
Mar 7 at 9:34
I've looked into padding with zeroes. It makes it even, but I don't want leading zeroes.
– user279955
Mar 7 at 9:36
I've looked into padding with zeroes. It makes it even, but I don't want leading zeroes.
– user279955
Mar 7 at 9:36
@user279955 Can you show us the code you use to make the plot (or at least the code which adds the text to the plot) ?
– Ralf
Mar 7 at 9:55
@user279955 Can you show us the code you use to make the plot (or at least the code which adds the text to the plot) ?
– Ralf
Mar 7 at 9:55
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55039967%2fjoin-a-list-of-numbers-into-a-string-maintain-overall-spacing-between-elements%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55039967%2fjoin-a-list-of-numbers-into-a-string-maintain-overall-spacing-between-elements%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What do you mean by plotting text?
– FChm
Mar 7 at 9:14
Possible duplicate of Nicest way to pad zeroes to a string
– meowgoesthedog
Mar 7 at 9:33
plotting text with plt.text over a graph. i've added a pic to help
– user279955
Mar 7 at 9:34
I've looked into padding with zeroes. It makes it even, but I don't want leading zeroes.
– user279955
Mar 7 at 9:36
@user279955 Can you show us the code you use to make the plot (or at least the code which adds the text to the plot) ?
– Ralf
Mar 7 at 9:55