cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Emmerich38
Level II

How change "E" for powers of 10

Hello,

For a publication in a scientific paper I made graph under JMP 17 (file attached). Editor asks me to change the "E" for powers of 10. In other words, 3.4 × 10⁵ instead of 3.4e+5. Could you please tell me if there is an easy way to do this ?

Thanks in advance,

best regards

Sébastien

8 REPLIES 8
jthi
Super User

Re: How change "E" for powers of 10

Emmerich38
Level II

Re: How change "E" for powers of 10

Hello,

Thank you for your quick reply. Now it is like this. Do you think it is possible to adapt the formula to have this representation? 3.4 × 10⁵ ? Without the ^, but with the number in the exponent ?

puissance3.JPG

Thanks in advance.

Best regards

Sébastien

 

jthi
Super User

Re: How change "E" for powers of 10

Try with custom format like this.

keys = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
values = {"\!U2070", "\!U00B9", "\!U00B2", "\!U00B3", "\!U2074", "\!U2075", "\!U2076", "\!U2077", "\!U2078", "\!U2079"};
superscripts = Associative Array(keys, values);

valstr = Format(value, "Scientific");
exp = Word(-1, valstr, "+");
e_sup = Transform Each({e_val}, Words(exp, ""), superscripts[e_val]);
exp_superscripts = Concat Items(e_sup, "");

val = Word(1, valstr, "+");
final_val = Substitute(val, "e", "×10" || exp_superscripts);

You might have to add some if statements to handle some specific situations if the format isn't correct

 

Names Default To Here(1);

dt = New Table("demo",
	Add Rows(13),
	Compress File When Saved(1),
	New Column("Column 1",
		Numeric,
		"Continuous",
		Format("Scientific", 64),
		Set Values(
			[1, 10, 20, 2.5, 200, 2000, 20000, 200000, 2000000, 2000000, 20000000000,
			2000000000000, 2.22222222222222e+19]
		),
		Set Display Width(155)
	),
	New Column("Column 2",
		Numeric,
		"Continuous",
		Format(
			"Custom",
			Formula(
				keys = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
				values = {"⁰", "¹", "²", "³", "⁴", "⁵", "⁶", "⁷", "⁸", "⁹"};
				superscripts = Associative Array(keys, values);
				valstr = Format(value, "Scientific");
				exp = Word(-1, valstr, "+");
				e_sup = Transform Each({e_val}, Words(exp, ""), superscripts[e_val]);
				exp_superscripts = Concat Items(e_sup, "");
				val = Word(1, valstr, "+");
				final_val = Substitute(val, "e", "×10" || exp_superscripts);
			),
			64,
			0
		),
		Set Values(
			[1, 10, 20, 2.5, 200, 2000, 20000, 200000, 2000000, 2000000, 20000000000,
			2000000000000, 2.22222222222222e+19]
		),
		Set Display Width(134)
	)
);

 

jthi_1-1708695194819.png

jthi_2-1708695297421.png

 

-Jarmo
jthi
Super User

Re: How change "E" for powers of 10

I also think it might be worth to create a wish list item for this (if there isn't one).

-Jarmo
Emmerich38
Level II

Re: How change "E" for powers of 10

I saw that there is a wish list dating back to 2022. As I'm a beginner, I don't understand where I should put the script you presented above.

Could you give me a step by step description or a link to learn how I can do this.

Thanks in advance.

Yours faithfully

 

jthi
Super User

Re: How change "E" for powers of 10

One thing my script doesn't currently take into account are negative exponents, but your data didn't seem to have those, so I didn't implement them.

 

Open your column properties (right click -> column info, or just double click on the header)

jthi_0-1708701918985.png

From format go to Custom

jthi_1-1708701955957.png

Then click Set Custom format. On the (formula) editor copy and paste

keys = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"};
values = {"\!U2070", "\!U00B9", "\!U00B2", "\!U00B3", "\!U2074", "\!U2075", "\!U2076", "\!U2077", "\!U2078", "\!U2079"};
superscripts = Associative Array(keys, values);

valstr = Format(value, "Scientific");
exp = Word(-1, valstr, "+");
e_sup = Transform Each({e_val}, Words(exp, ""), superscripts[e_val]);
exp_superscripts = Concat Items(e_sup, "");

val = Word(1, valstr, "+");
final_val = Substitute(val, "e", "×10" || exp_superscripts);

jthi_2-1708702001023.png

click ok to close the editor. Then apply and OK to apply your format

jthi_3-1708702026996.png

jthi_4-1708702035145.png

 

-Jarmo
Emmerich38
Level II

Re: How change "E" for powers of 10

Thanks a lot, I copied your script in the custom section over the graphic and it works.

Have a nice day!

jthi
Super User

Re: How change "E" for powers of 10

There is also blog postReply All: Scientific notation such as 6.02×10²³ using custom axis formats which has different custom formula which also takes the negative exponent into account. Here is my modified version of the version from the blog post by Xan (biggest change is to use Words() in Substitute Into to remove need for loop).

 

For scripting this can be used

Local({
	supers = "⁰¹²³⁴⁵⁶⁷⁸⁹⁻",
	numbers = "0123456789-",
	numpart, exprpart
},
	supers = "⁰¹²³⁴⁵⁶⁷⁸⁹⁻";
	numbers = "0123456789-";
	{numpart, exppart} = Words(Format(value, "Scientific", width, dec), "e+");
	Substitute Into(exppart, "+", "", Words(numbers, ""), Words(supers, ""));
	If(value == 0, 
		"0";
	, 
		numpart || " × 10" || exppart;
	);
);

And for easy copypaste this works (locals not used)

supers = "⁰¹²³⁴⁵⁶⁷⁸⁹⁻";
numbers = "0123456789-";
{numpart, exppart} = Words(Format(value, "Scientific", width, dec), "e+");
Substitute Into(exppart, "+", "", Words(numbers, ""), Words(supers, ""));
If(value == 0, 
	"0";
, 
	numpart || " × 10" || exppart;
);

 

-Jarmo