Changeset 616
- Timestamp:
- 09/15/16 00:07:27 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/mds_plot.py
r613 r616 103 103 104 104 105 def plot(coordinates, labels, dimensions, variance_fraction, jitter, flipX, flipY, outname=""):105 def plot(coordinates, labels, dimensions, variance_fraction, jitter, flipX, flipY, swapXY, outname=""): 106 106 fig = plt.figure() 107 107 … … 118 118 if flipY: 119 119 coordinates=np.hstack((coordinates[:, [0]], -coordinates[:, [1]])) 120 if swapXY: 121 coordinates[:,[0, 1]] = coordinates[:,[1, 0]] 120 122 121 123 add_jitter = lambda tab: rand_jitter(tab, jitter) if jitter>0 else tab … … 158 160 159 161 160 def main(filename, dimensions=3, outname="", jitter=0, separator='\t', flipX=False, flipY=False ):162 def main(filename, dimensions=3, outname="", jitter=0, separator='\t', flipX=False, flipY=False, swapXY=False): 161 163 distances,labels = read_file(filename, separator) 162 164 embed,variance_fraction = compute_mds(distances, dimensions) … … 165 167 embed = np.array([np.insert(e, 0, 0, axis=0) for e in embed]) 166 168 167 plot(embed, labels, dimensions, variance_fraction, jitter, flipX, flipY, outname)169 plot(embed, labels, dimensions, variance_fraction, jitter, flipX, flipY, swapXY, outname) 168 170 169 171 … … 177 179 parser.add_argument('--flipX', required=False, dest='flipX', action='store_true') 178 180 parser.add_argument('--flipY', required=False, dest='flipY', action='store_true') 181 parser.add_argument('--swapXY', required=False, dest='swapXY', action='store_true') 179 182 parser.set_defaults(flipX=False) 180 183 parser.set_defaults(flipY=False) 184 parser.set_defaults(swapXY=False) 181 185 182 186 args = parser.parse_args() 183 187 set_value = lambda value, default: default if value == None else value 184 main(args.input, int(set_value(args.dim, 3)), set_value(args.output, ""), float(set_value(args.j, 0)), set_value(args.sep, "\t"), args.flipX, args.flipY )188 main(args.input, int(set_value(args.dim, 3)), set_value(args.output, ""), float(set_value(args.j, 0)), set_value(args.sep, "\t"), args.flipX, args.flipY, args.swapXY)
Note: See TracChangeset
for help on using the changeset viewer.