cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-67331%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EWie%20schreibe%20ich%20ein%20Skript%2C%20um%20eine%20bestimmte%20Zeile%20f%C3%BCr%20das%20Plot-Balkendiagramm%20zu%20verwenden%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-67331%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHallo%20alle!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIch%20m%C3%B6chte%20ein%20Balkendiagramm%20mit%20einer%20bestimmten%20Zeile%20in%20der%20Datentabelle%20zeichnen.%20Das%20Format%20der%20Tabelle%20ist%20wie%20folgt%3A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22photo.png%22%20style%3D%22width%3A%20736px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22photo.png%22%20style%3D%22width%3A%20736px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22photo.png%22%20style%3D%22width%3A%20736px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F11923i7065B6928E0D5E66%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22photo.png%22%20alt%3D%22photo.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIch%20bin%20mir%20nicht%20sicher%2C%20was%20der%20beste%20Weg%20ist%2C%20es%20zu%20tun.%3C%2FP%3E%3CP%3EMein%20Gedanke%20ist%2C%20die%20Zeile%20auszuw%C3%A4hlen%2C%20sie%20in%20einer%20neuen%20Datentabelle%20zu%20speichern%2C%20die%20neue%20Tabelle%20zu%20transponieren%20und%20dann%20die%20beiden%20Spalten%20in%20der%20neuen%20Datentabelle%20zu%20verwenden%2C%20um%20den%20Balken%20zu%20zeichnen.%20Das%20Skript%20f%C3%BCr%20diese%20Methode%20ist%20etwas%20lang%2C%20daher%20w%C3%BCrde%20ich%20gerne%20wissen%2C%20ob%20es%20einen%20einfacheren%20Weg%20daf%C3%BCr%20gibt.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EJede%20Hilfe%20wird%20sehr%20gesch%C3%A4tzt!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-67349%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20schreibe%20ich%20ein%20Skript%2C%20um%20eine%20bestimmte%20Zeile%20f%C3%BCr%20das%20Plot-Balkendiagramm%20zu%20verwenden%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-67349%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDie%20%22values(%20dt%5B0%2C%205%5D%20)%22%20beziehen%20sich%20auf%20die%20Werte%2C%20die%20in%20die%20Datentabelle%20eingef%C3%BCgt%20werden%20sollen.Das%20%22dt%5B0%2C5%5D%22%20bezieht%20sich%20auf%20die%205.%20Zeile%20in%20der%20Datentabelle.Es%20war%20tats%C3%A4chlich%20ein%20Fehler%20in%20meinem%20Code%2C%20es%20h%C3%A4tte%20%22values(%20dt%5B5%2C%200%5D%20)%22%20sein%20sollen.Die%20%E2%80%9E0%E2%80%9C%20bezieht%20sich%20auf%20alle%20Spalten%20in%20der%20Datentabelle.Ich%20habe%20meinen%20Code%20unten%20ge%C3%A4ndert%2C%20um%20die%20neue%20Anforderung%20zu%20erf%C3%BCllen.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2Fblood%20pressure.jmp%22%20)%3B%0Adt%20%26lt%3B%26lt%3B%20delete%20columns(%201%2C%202%20)%3B%0A%0ArowNum%20%3D%205%3B%0A%0AcolNames%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(string)%3B%0A%0A%0Adt2%20%3D%20New%20Table(%20%22example%22%2C%0A%20New%20Column(%20%22Label%22%2C%20character%2C%20values(%20colNames%20)%20)%2C%0A%20New%20Column(%20%22Row%20%22%20%7C%7C%20char(%20rowNum%20)%2C%20values(%20dt%5BrowNum%2C%200%20%5D%20)%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-67341%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20schreibe%20ich%20ein%20Skript%2C%20um%20eine%20bestimmte%20Zeile%20f%C3%BCr%20das%20Plot-Balkendiagramm%20zu%20verwenden%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-67341%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDanke%20f%C3%BCr%20deine%20Antwort%20Jim!%3CBR%20%2F%3E%20Ich%20verstehe%20jedoch%20nicht%2C%20was%20%22values(%20dt%5B0%2C%205%5D%20)%22%20hier%20bedeutet.%20Wie%20kann%20ich%20einfach%20die%20Zeile%20ausw%C3%A4hlen%2C%20die%20ich%20f%C3%BCr%20das%20Diagramm%20haben%20m%C3%B6chte%3F%20In%20meinem%20Fall%20m%C3%B6chte%20ich%20beispielsweise%20nur%20Zeile%20132%20als%20numerische%20Werte%20auf%20der%20Y-Achse%20f%C3%BCr%20das%20Diagramm%20und%20die%20Namen%20der%20Spalten%20als%20kategorische%20Namen%20auf%20der%20X-Achse%20ausw%C3%A4hlen.%20Die%20erwartete%20Handlung%20ist%20wie%20folgt%3A%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22figure.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22figure.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22figure.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F11924i369CBFB4FC066BF8%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22figure.png%22%20alt%3D%22figure.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-67334%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Wie%20schreibe%20ich%20ein%20Skript%2C%20um%20eine%20bestimmte%20Zeile%20f%C3%BCr%20das%20Plot-Balkendiagramm%20zu%20verwenden%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-67334%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHier%20ist%20ein%20einfaches%20Beispiel%20f%C3%BCr%20eine%20M%C3%B6glichkeit%2C%20das%20zu%20tun%2C%20was%20Sie%20wollen%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2Fblood%20pressure.jmp%22%20)%3B%0Adt%20%26lt%3B%26lt%3B%20delete%20columns(%201%2C%202%20)%3B%0A%0A%0Adt2%20%3D%20New%20Table(%20%22example%22%2C%20New%20Column(%20%22transpose%22%2C%20values(%20dt%5B0%2C%205%5D%20)%20)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
vistacc
Level III

How to write a script to use a specific row for plot bar chart?

Hi all!

 

I want to plot a bar chart using a specific row in the data table. The format of the table is as following:photo.png

 

I am not sure what is the best way to do it.

My thought is to select the row, save it to a new data table, transpose the new table and then use the two columns in the new data table to plot the bar. The script for this method is a little bit long so I would like to know whether there is a more simple way for it.

 

Any help will be greatly appreciated!

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to write a script to use a specific row for plot bar chart?

The "values( dt[0, 5] )" refers to the values to be placed into the data table.  The "dt[0,5]" referred to the 5th row in the data table.  It actually was an error in my code, it should have been, "values( dt[5, 0] )".  The "0" refers to all columns in the data table.  I have changed my code below to meet the new requirement.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dt << delete columns( 1, 2 );

rowNum = 5;

colNames = dt << get column names(string);


dt2 = New Table( "example",
	New Column( "Label", character, values( colNames ) ),
	New Column( "Row " || char( rowNum ), values( dt[rowNum, 0 ] ) ) );
Jim

View solution in original post

3 REPLIES 3
txnelson
Super User

Re: How to write a script to use a specific row for plot bar chart?

Here is a simple example of one way to do what you want

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dt << delete columns( 1, 2 );


dt2 = New Table( "example", New Column( "transpose", values( dt[0, 5] ) ) );
Jim
vistacc
Level III

Re: How to write a script to use a specific row for plot bar chart?

Thank you for your reply, Jim!
I don't get what "values( dt[0, 5] )" means here though. How can I just select the row that I want for the plot? For example, in my case, I only want to select row 132 as numeric values in y-axis for the plot and the names of the columns as the categorical names in the x-axis. Expected plot is as the following: figure.png

 

txnelson
Super User

Re: How to write a script to use a specific row for plot bar chart?

The "values( dt[0, 5] )" refers to the values to be placed into the data table.  The "dt[0,5]" referred to the 5th row in the data table.  It actually was an error in my code, it should have been, "values( dt[5, 0] )".  The "0" refers to all columns in the data table.  I have changed my code below to meet the new requirement.

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/blood pressure.jmp" );
dt << delete columns( 1, 2 );

rowNum = 5;

colNames = dt << get column names(string);


dt2 = New Table( "example",
	New Column( "Label", character, values( colNames ) ),
	New Column( "Row " || char( rowNum ), values( dt[rowNum, 0 ] ) ) );
Jim

Recommended Articles